Contiguous US Maps

knitr::opts_chunk$set(collapse = T, comment = "#>")
library(statesRcontiguous)

Visualising the contiguous United States

This package provides three different shapefiles for the United States of America, comprising; state boundaries, congressional districts and counties. These are stored as sf objects, if you're not familiar with the excellent sf approach to geometric features it's highly recommended you glace at the documentation - https://r-spatial.github.io/sf//index.html

The sf objects contain a column called contiguous.united.states which allows us to restrict ourselves to only the contiguous US. This is how we might visualise the congressional districts of the contiguous US with leaflet:

library("statesRcontiguous")
library("tidyverse")
library("leaflet")
shp_contiguous_us_congressional_districts <- shp_all_us_congressional_districts %>%
  filter(contiguous.united.states)
shp_contiguous_us_congressional_districts %>%
  leaflet() %>%
  addTiles() %>%
  addPolygons(weight = 1)

Where are the shapefiles from?

All of the shapefiles in this package are from the US Census website - https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html. This package will continuously be updated with the most recent shapefiles, historical shapefiles will not be available in this package. If that's what you want, please do use the tigris package - https://github.com/walkerke/tigris.

The explicit urls for the shapefiles are available here:

knitr::kable(shapefile_details)


Try the statesRcontiguous package in your browser

Any scripts or data that you put into this service are public.

statesRcontiguous documentation built on Aug. 7, 2017, 5:03 p.m.