This function allows you to download boundaries for state legislatures into R. Generally, state legislatures are comprised of an "upper" house, which is typically referred to as the Senate, and a "lower" house, which is often (but not exclusively) referred to as the House. The exception is Nebraska, which has a unicameral state legislature.
state_legislative_districts(
state = NULL,
house = "upper",
cb = FALSE,
year = NULL,
...
)
The two-digit FIPS code (string) of the state. Can also be state
name or abbreviation (case-insensitive). When NULL
and combined with
cb = TRUE
, a national dataset of state legislative districts will be returned.
Specify here whether you want boundaries for the upper
or
lower
house. Defaults to upper
.
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file).
the data year; defaults to 2024
arguments to be passed to internal function load_tiger
, which is not exported. See Additional Arguments.
Additional arguments that can be passed in ...
are:
class
Desired class of return object: "sf"
(the default) or "sp"
. sp classes should be considered deprecated as of tigris version 2.0, but legacy support is still available.
progress_bar
If set to FALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults to TRUE
.
keep_zipped_shapefile
If set to TRUE
, do not delete zipped shapefile (stored in temporary directory or TIGRIS_CACHE_DIR
depending on the configuration of global option "tigris_use_cache"
). Defaults to FALSE
.
refresh
Whether to re-download cached shapefiles (TRUE
or FALSE
) . The default is either FALSE
or the value of global
option "tigris_refresh"
if it is set. Specifying this argument will override the behavior set in "tigris_refresh"
global option.
filter_by
Geometry used to filter the output returned by the function. Can be an sf object, an object of class bbox
, or a length-4 vector of format c(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input to filter_by
will be returned.
protocol
Character string specifying the protocol to use for downloading files. Options are "ftp" or "http" (default). If "ftp", the URL will be modified to use FTP instead of HTTPS.
timeout
Integer specifying the timeout in seconds for download operations if protocol is "ftp". Defaults to 1800 (30 minutes) to handle large files.
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/state-legis-dist.html
Other legislative district functions:
congressional_districts()
,
voting_districts()
if (FALSE) {
library(tigris)
library(leaflet)
leg <- state_legislative_districts("Maine", "lower", cb = TRUE)
leaflet(leg) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5)
}
Run the code above in your browser using DataLab