Skip to contents

View congressional district boundaries on an interactive Mapbox map. Useful for seeing how much a district overlaps with a city, or comparing multiple district maps together.

Usage

cd_mapbox(
  cd = NULL,
  congress,
  state = NULL,
  cities = NULL,
  zoom_to_cities = FALSE,
  colors = c("#2166AC", "#D95F02", "#009E73"),
  detailed = TRUE
)

Arguments

cd

Character district code with a two-letter state abbreviation and a two-digit district number, such as "TN-09". At-large districts use "01", such as "DE-01".

congress

Integer vector of Congress numbers, such as 119 or c(119, 120).

state

State names, two-letter abbreviations, or FIPS codes, such as "Tennessee", "TN", or 47.

cities

A character name like "Memphis" or "San Bernardino" to highlight in the map.

zoom_to_cities

Default to have mapbox zoom into the city, if specified? Defaults to FALSE.

colors

Colors for district lines. Accepts up to three, for different Congresses.

detailed

Use full-resolution Census TIGER/Line district boundaries for modern Congresses and unsimplified historical boundaries? Defaults to TRUE, suitable for zooming into cities. Set FALSE for smaller, generalized maps. City boundaries always use full-resolution TIGER/Line.

Value

A mapgl Mapbox HTML widget.

Details

Supply exactly one district with cd or one state with state, and one to three Congress numbers from 1-120 with congress.

detailed = FALSE restores the lighter cartographic boundaries for modern Congresses. Redrawn 120th-Congress districts and North Carolina's special 117th-Congress plan retain their original detailed sources in either mode.

City outlines only use 2026 Census incorporated-place boundaries, shared across the compared Congresses. They do not represent historical municipal boundaries. Alaska and Hawaii are excluded because the package's boundaries use insets.

See also

mapbox-setup for account setup, access tokens, and free usage limits.

Other congressional district functions: cd_available(), cd_boundaries(), cd_dotmap(), cd_hexmap(), cd_names(), cd_normal_vote()

Author

Codex

Examples

if (FALSE) { # \dontrun{
cd_mapbox(state = "TN", congress = c(119, 120), cities = "Memphis")
cd_mapbox("TN-09", congress = c(119, 120))
} # }