Skip to contents

Visualize the population-weighted representative point selection for one or more census tracts. Shows the population raster, identified clusters, OSM roads, and the selected departure point.

Usage

plot_representative_points(
  result,
  tracts_sf = NULL,
  pop_raster = NULL,
  tract = NULL,
  osm_roads = NULL,
  ...
)

Arguments

result

An interpElections_result object, or an sf POINT object returned by compute_representative_points().

tracts_sf

Census tract polygons. Extracted from result if available, otherwise required.

pop_raster

A terra::SpatRaster or NULL. Extracted from result if available. Required for single-tract detail view.

tract

Character vector. Tract IDs to plot in detail. If NULL (default), shows a summary map of all tracts.

osm_roads

An sf object with road geometries, or NULL. Extracted from result if available.

...

Ignored.

Value

A ggplot object (invisibly).

Examples

if (FALSE) { # \dontrun{
result <- interpolate_election_br(3170701, 2022,
             keep = c("pop_raster", "osm_roads"))

# Summary: all tracts with cluster counts
plot_representative_points(result)

# Detail: single tract showing raster, clusters, roads, point
plot_representative_points(result, tract = "317070105000138")
} # }