explode_section() is a dashboard-oriented helper for exploratory maps.
It applies an exploded layout only to the requested section, then recombines
the untouched remainder of the layer as geographic context. The result can
be passed directly to focus_map() with context_col to fade or hide the
non-selected features.
Arguments
- sf_obj
Projected
sfobject.- section_col
Column containing the high-level sections users choose from, such as
"North","Central", and"South".- section
Selected section value. Values in
all_valuesexplode the full layer.- region_col
Column used for the explosion inside the selected section. Defaults to
section_col. For municipality drill-downs, this is often a county column.- layout
"explode"forexplode_sf()or"grouped"forexplode_grouped().- context
"fade"or"hide"keeps non-selected features in the returned object as context;"none"drops them.- role_col
Name of the role column added to the output. Focus features are marked
"focus"and context features are marked"context".- all_values
Values that mean "all sections". Default
"all".- ...
Passed to
explode_sf()orexplode_grouped().
Value
An exploded_map or grouped_exploded_map object with recombined
focus/context geometry and extra diagnostics.
Examples
# \donttest{
poly <- function(xmin, ymin, xmax, ymax) {
sf::st_polygon(list(rbind(
c(xmin, ymin), c(xmax, ymin), c(xmax, ymax),
c(xmin, ymax), c(xmin, ymin)
)))
}
municipalities <- sf::st_sf(
NAME = c("A", "B", "C", "D"),
nj_region = c("South", "South", "North", "North"),
county_name = c("Atlantic", "Cape May", "Bergen", "Hudson"),
geometry = sf::st_sfc(
poly(0, 0, 1000, 1000),
poly(2000, 0, 3000, 1000),
poly(0, 2000, 1000, 3000),
poly(2000, 2000, 3000, 3000),
crs = 3857
)
)
focused <- explode_section(
municipalities,
section_col = "nj_region",
section = "South",
region_col = "county_name",
alpha_r = 1800,
alpha_l = 1200,
plot = FALSE,
quiet = TRUE
)
focus_map(
focused,
label_col = "NAME",
context_col = ".explodemap_role",
context_mode = "fade"
)
# }
