Skip to contents

Generate an SSU schema by deriving class intervals. Wrapper around classIntervals. SSU schemas are generally used as a reference to partition secondary sampling units in wt_strata.

For converting a named list or dataframe with threshold intervals, use ssu_schema. proto_schema is particularly for prototyping or generating schemas from data and should only be used for testing purposes.

Usage

proto_schema(
  weights,
  ssu,
  type = "fixed",
  style = "quantile",
  closure = "left",
  ...,
  drop_zero = TRUE
)

Arguments

weights

An object of class sf, sfc, SpatVector, or SpatRaster that is later used for wt_strata.

ssu

Factor representing the secondary sampling unit (SSU) in wt_strata. For reasonable results, the levels should be ordinal and ordered ascending.

style

Method to generate thresholds. Passed to classIntervals.

...

Further arguments passed to ssu_schema.

drop_zero

Whether to remove all zeroes from weights. Can be useful to prevent biases in rasters that are predominantly zero.

x

A named list or dataframe containing interval information. Lists are expected to be named and contain two numeric values per list element (the lower and upper boundaries). Dataframes are expected to contain at least three columns where the first column is the factor value and the other two columns are the lower and upper boundaries.

Value

A schema, i.e. a named list containing thresholds or benchmarks for each name.

Examples

dummy <- dummy_data()

# derive schema from data
proto_schema(dummy$pop, dummy$survey$place_type)
#> SSU schema using fixed thresholds
#> Points are only sampled within these thresholds.
#> 
#> Village = [50, 280)
#> Town    = [280, 500)
#> Suburb  = [500, 1700)
#> City    = [1700, 2500] 
proto_schema(dummy$pop, dummy$survey$place_type, style = "kmeans")
#> SSU schema using fixed thresholds
#> Points are only sampled within these thresholds.
#> 
#> Village = [50, 700)
#> Town    = [700, 1425)
#> Suburb  = [1425, 2025)
#> City    = [2025, 2500]