Skip to contents

Assembles a wide leaftable table from a set of two-column crosswalks. Each crosswalk is a data.frame whose column names are two geoframe names; the builder joins them together, starting from the finest geoframe, until every geoframe in geoframes is present.

Usage

geoscale_build(
  ...,
  geoframes,
  weights = NULL,
  name = "",
  desc = "",
  row_order = c("nested", "given")
)

Arguments

...

Additional arguments passed to geoscale_from_leaftable().

geoframes

Ordered character vector of geoframe names, coarsest first. The last entry is the leaf geoframe.

weights

Optional data.frame keyed by the leaf geoframe, carrying one or more numeric weight columns.

name, desc

Short name and description.

row_order

Passed to geoscale_from_leaftable(): "nested" (default) or "given".

Value

A GeoScale.

Details

Crosswalks need not form a strict chain: a geoframe that cross-cuts the others (a grid zone crossing state lines, say) is expressed simply by giving its crosswalk against the finest geoframe.

Examples

geoscale_build(
  data.frame(country = c("N", "N", "S"),
             state   = c("N1", "N2", "S1")),
  data.frame(state = c("N1", "N1", "N2", "S1"),
             cell  = c("A1", "A2", "A3", "A4")),
  geoframes  = c("country", "state", "cell"),
  weights = data.frame(cell = c("A1", "A2", "A3", "A4"),
                       km2  = c(10, 20, 30, 40))
)
#> GeoScale: country_state_cell 
#> Geoframes (3, coarsest first):
#>   - country (2)
#>     - state (3)
#>       - cell (4)
#> Leaves: 4
#> Weights: km2 (default: km2)