Skip to contents

Builds a new geoframe that keeps focus leaves at full resolution and collapses everything else into progressively coarser rings drawn from geoframes. The result is a partition of the leaves, carried as a geoframe.

Usage

zoom_geoscale(
  x,
  focus,
  geoframes = NULL,
  name = "zoom",
  label_rest = "%s_rest"
)

Arguments

x

A GeoScale.

focus

Character vector of leaf codes to keep at full resolution.

geoframes

Ordered geoframes to build rings from, coarsest first. Defaults to every geoframe of x except the leaf layer.

name

Name of the new geoframe. Default "zoom".

label_rest

sprintf format for a ring's code, with %s the parent code. Default "%s_rest".

Value

A GeoScale with geoframes geoframes[1], name and the leaf geoframe; weights and geometry carried through unchanged.

Details

With focus leaves and geoframes = c("nuts0", "nuts1", "nuts2") (coarsest first), each remaining leaf joins the finest ring that also contains a focus leaf, so the cut telescopes outward:

  • the focus leaves themselves, individually;

  • the rest of each nuts2 holding a focus leaf;

  • the rest of each nuts1 holding one of those;

  • the rest of each nuts0 holding one of those;

  • every other leaf, grouped in geoframes[1].

The intermediate geoframes are dropped. A ring like "rest of nuts1" spans several nuts2, so the cut cannot nest with the geoframes it was carved from; only geoframes[1] and the leaf geoframe are kept beside it. That is checked, not assumed – see geoscale_nests().

See also

filter_geoscale() to sample, prune_geoscale() to coarsen uniformly, geoscale_nests() for the guarantee this relies on.

Examples

gs <- geoscale_example()
z <- zoom_geoscale(gs, focus = "A1",
                   geoframes = c("country", "state"))
geoscale_geoframes(z)
#> [1] "country" "zoom"    "cell"   
geoscale_regions(z, "zoom")
#> [1] "A1"      "N1_rest" "N_rest"  "S"