Skip to contents

The counterpart of geoscale_map() for two GeoScales: leaves are matched on their codes, so a region of source overlaps a region of target where they contain the same leaves. Same columns as geoscale_map(), with the two label columns named after the GeoScales. Leaves of source absent from target get an NA target (with a warning). A crosswalk registered with register_geoscale_map_between() is returned as-is instead of being derived.

Usage

geoscale_map_between(
  source,
  target,
  weight = NULL,
  from = lifecycle::deprecated(),
  to = lifecycle::deprecated()
)

Arguments

source, target

Two named GeoScale objects whose leaf codes overlap.

weight

Weight column of source for w; NULL uses its default weight, or weight 1 per leaf when it declares none.

from, to

Deprecated names of source and target.

Value

A data.frame with columns <from name>, <to name>, n_from, n_overlap, w, w_from.

Examples

gs <- geoscale_example()
# another hierarchy over the same leaves (ROW has no counterpart: NA target)
bands <- geoscale_from_leaftable(
  data.frame(
    band = rep(c("X", "Y"), 3),
    cell = c("A1", "A2", "A3", "A4", "A5", "A6"),
    km2 = c(100, 200, 300, 400, 500, 600)
  ),
  geoframes = c("band", "cell"), name = "bands"
)
geoscale_map_between(gs, bands)
#> Warning: 1 leaf row(s) of "example" have no counterpart in "bands"; their share is uncovered (NA target)
#>   example bands n_from n_overlap    w w_from
#> 1      A1    A1      1         1  100    100
#> 2      A2    A2      1         1  200    200
#> 3      A3    A3      1         1  300    300
#> 4      A4    A4      1         1  400    400
#> 5      A5    A5      1         1  500    500
#> 6      A6    A6      1         1  600    600
#> 7     ROW  <NA>      1         1 1000   1000