% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/section.R
\name{explode_section}
\alias{explode_section}
\title{Explode one selected section and keep the rest as context}
\usage{
explode_section(
  sf_obj,
  section_col,
  section,
  region_col = section_col,
  layout = c("explode", "grouped"),
  context = c("fade", "hide", "none"),
  role_col = ".explodemap_role",
  all_values = "all",
  ...
)
}
\arguments{
\item{sf_obj}{Projected \code{sf} object.}

\item{section_col}{Column containing the high-level sections users choose
from, such as \code{"North"}, \code{"Central"}, and \code{"South"}.}

\item{section}{Selected section value. Values in \code{all_values} explode the
full layer.}

\item{region_col}{Column used for the explosion inside the selected section.
Defaults to \code{section_col}. For municipality drill-downs, this is often a
county column.}

\item{layout}{\code{"explode"} for \code{\link[=explode_sf]{explode_sf()}} or \code{"grouped"} for
\code{\link[=explode_grouped]{explode_grouped()}}.}

\item{context}{\code{"fade"} or \code{"hide"} keeps non-selected features in the
returned object as context; \code{"none"} drops them.}

\item{role_col}{Name of the role column added to the output. Focus features
are marked \code{"focus"} and context features are marked \code{"context"}.}

\item{all_values}{Values that mean "all sections". Default \code{"all"}.}

\item{...}{Passed to \code{\link[=explode_sf]{explode_sf()}} or \code{\link[=explode_grouped]{explode_grouped()}}.}
}
\value{
An \code{exploded_map} or \code{grouped_exploded_map} object with recombined
focus/context geometry and extra diagnostics.
}
\description{
\code{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 \code{\link[=focus_map]{focus_map()}} with \code{context_col} to fade or hide the
non-selected features.
}
\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"
)
}
}
