Type: | Package |
Title: | Load Census TIGER/Line Shapefiles |
Version: | 2.2.1 |
Date: | 2025-04-15 |
URL: | https://github.com/walkerke/tigris |
BugReports: | https://github.com/walkerke/tigris/issues |
Description: | Download TIGER/Line shapefiles from the United States Census Bureau (https://www.census.gov/geographies/mapping-files/time-series/geo/tiger-line-file.html) and load into R as 'sf' objects. |
License: | MIT + file LICENSE |
LazyData: | TRUE |
Encoding: | UTF-8 |
Depends: | R (≥ 3.3.0) |
Suggests: | testthat, ggplot2, ggthemes, leaflet, knitr, tidycensus, sp |
Imports: | stringr, magrittr, utils, rappdirs, httr, uuid, sf, dplyr, methods |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-04-16 16:09:54 UTC; kylewalker |
Author: | Kyle Walker [aut, cre], Bob Rudis [ctb] |
Maintainer: | Kyle Walker <kyle@walker-data.com> |
Repository: | CRAN |
Date/Publication: | 2025-04-16 16:40:02 UTC |
Download and use U.S. Census TIGER shapefiles in R
Description
tigris is an R package that allows users to directly download and use TIGER/Line and cartographic boundary shapefiles from the US Census Bureau in R. For an overview of the package, visit its repository at https://github.com/walkerke/tigris or read Chapter 5 of the book Analyzing US Census Data: Methods, Maps, and Models in R at https://walker-data.com/census-r/census-geographic-data-and-applications-in-r.html.
Details
Use option tigris_use_cache
to tell tigris
to cache
Census shapefile downloads. This is FALSE
by default. e.g.
options(tigris_use_cache=TRUE)
Use option tigris_refresh
to force a refresh of cached tigris
Shapefiles. e.g. options(tigris_refresh=TRUE)
Use option tigris_year
to change the year for which you'd like to download data.
e.g. options(tigris_year = 2017)
. The default year for the package is 2022.
Use option tigris_class
to specify the class of spatial object you'd like returned.
The default is "sf"
for simple features objects. If you'd like a legacy object
of class Spatial*DataFrame
, use options(tigris_class = "sp")
. Please note
that legacy sp objects are no longer formally supported in tigris.
Use the protocol
argument in data download functions to specify whether to use FTP or HTTP
for downloading files. The default is "ftp"
, which may work better in some environments
where HTTPS connections are restricted. For HTTPS downloads, use protocol = "http"
.
Use the timeout
parameter to control the timeout for downloading large files when the protocol is FTP. The default is
1800 seconds (30 minutes), which should be sufficient for most files. If you're downloading particularly
large files or have a slow connection, you may need to increase this value.
Note
Several options
and arguments control behavior of various tigris
functions.
See Details
for more information.
Author(s)
Kyle Walker (@kyle_e_walker)
See Also
Useful links:
Download an address range features shapefile into R
Description
Download an address range features shapefile into R
Usage
address_ranges(state, county, year = NULL, ...)
Arguments
state |
The two-digit FIPS code of the state of the county you'd like to download the roads for. Can also be state name or abbreviation (case-insensitive). |
county |
The three-digit FIPS code of the county you'd like the roads for. Can also be a county name. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other transportation functions:
primary_roads()
,
primary_secondary_roads()
,
rails()
,
roads()
Download an Alaska Native Regional Corporation shapefile into R.
Description
From the US Census Bureau: "ANRCs are corporations created according to the Alaska Native Claims Settlement Act. They are organized under the laws of the State of Alaska as "Regional Corporations," to conduct both the for-profit and non-profit affairs of Alaska Natives within defined regions of Alaska." For more information, please see the Census technical documentation at the link provided.
Usage
alaska_native_regional_corporations(cb = FALSE, year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch5GARM.pdf
Other native/tribal geometries functions:
native_areas()
,
tribal_block_groups()
,
tribal_census_tracts()
,
tribal_subdivisions_national()
Retrieve GEOID from the Census Geocoder by address
Description
Returns GEOID for 2020 geographies.
Usage
append_geoid(address, geoid_type = "block")
Arguments
address |
A tibble/data frame with (at a minimum, others can be present) either character columns street, city, and state OR numeric columns lat and lon. Lat/lon columns take priority. |
geoid_type |
GEOID level to return, |
Value
the original tibble with GEOIDs appended as a new column called
geoid
.
Author(s)
Josie Kressner, josie@transportfoundry.com
Examples
## Not run:
airports <- dplyr::data_frame(
street = "700 Catalina Dr", city = "Daytona Beach", state = "FL"
)
append_geoid(airports, 'tract')
## End(Not run)
Download an area water shapefile into R
Description
From the US Census Bureau: "The area hydrography shapefile contains the geometry and attributes of both perennial and intermittent area hydrography features, including ponds, lakes, oceans, swamps, glaciers, and the area covered by large streams represented as double-line drainage."
Usage
area_water(state, county, year = NULL, ...)
Arguments
state |
The two-digit FIPS code of the state of the county you'd like to download the water features for. Can also be state name or abbreviation (case-insensitive). |
county |
The three-digit FIPS code of the county you'd like the water features for. Can also be a county name. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other water functions:
coastline()
,
linear_water()
Examples
## Not run:
library(tigris)
dallas_water <- area_water("TX", "Dallas")
plot(dallas_water$geometry)
## End(Not run)
Download a Census block groups shapefile into R, and optionally subset by county
Description
Description from the US Census Bureau (see link for source):Standard block groups are clusters of blocks within the same census tract that have the same first digit of their 4-character census block number. For example, blocks 3001, 3002, 3003..., 3999 in census tract 1210.02 belong to Block Group 3. Due to boundary and feature changes that occur throughout the decade, current block groups do not always maintain these same block number to block group relationships. For example, block 3001 might move due to a census tract boundary change but the block number will not change, even if it does not still fall in block group 3. However, the GEOID for that block, identifying block group 3, would remain the same in the attribute information in the TIGER/Line Shapefiles because block GEOIDs are always built using the decennial geographic codes.
Usage
block_groups(state = NULL, county = NULL, cb = FALSE, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also
be state name or state abbreviation. When |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
Block groups delineated for the 2010 Census generally contain between 600 and 3,000 people. Most block groups were delineated by local participants in the Census Bureau's Participant Statistical Areas Program (PSAP). The Census Bureau delineated block groups only where a local or tribal government declined to participate or where the Census Bureau could not identify a potential local participant.
A block group usually covers a contiguous area. Each census tract contains at least one block group and block groups are uniquely numbered within census tract. Within the standard census geographic hierarchy, block groups never cross county or census tract boundaries, but may cross the boundaries of county subdivisions, places, urban areas, voting districts, congressional districts, and American Indian, Alaska Native, and Native Hawaiian areas.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other general area functions:
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
benton_bgs <- block_groups("Oregon", "Benton")
plot(benton_bgs$geometry)
## End(Not run)
Download a Census block shapefile into R
Description
Description from the US Census Bureau (see link for source): Census blocks are statistical areas bounded on all sides by visible features, such as streets, roads, streams, and railroad tracks, and by non-visible boundaries such as city, town, township, and county limits, and short line-of-sight extensions of streets and roads. Generally, census blocks are small in area; for example, a block in a city. Census blocks in suburban and rural areas may be large, irregular and bounded by a variety of features, such as roads, streams, and/or transmission line rights-of-way. In remote areas census blocks may encompass hundreds of square miles. Census blocks cover all territory in the United States, Puerto Rico, and the Island areas. Blocks do not cross the boundaries of any entity for which the Census Bureau tabulates data.
Usage
blocks(state, county = NULL, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also be state name or state abbreviation. |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
This function will download an entire block shapefile for a selected state into R, and optionally subset by county. A warning: Census block shapefiles are often very large, especially for large states - for example, the block file for Texas is 462MB zipped! If you have a slow or unreliable internet connection, or insufficient memory, this may prove burdensome given that you have to first download by state and then subset.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other general area functions:
block_groups()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
# Simple example using Rose Island, American Samoa
# Be careful with Census blocks for states!
library(tigris)
library(leaflet)
rose_island <- blocks(state = "AS", county = "Rose Island")
leaflet(rose_island) %>%
addTiles() %>%
addPolygons()
## End(Not run)
Call geolocator for one address
Description
Call geolocator for one address
Usage
call_geolocator(street, city, state, zip = NA)
Arguments
street |
A character string indicating a street name and number |
city |
A character string indicating a city |
state |
A two-digit character string with a state postal code |
zip |
A five-digit character string with a postal zip code. Optional parameter. |
Value
A character string representing the Census block of the supplied address.
importFrom utils URLencode importFrom httr GET stop_for_status
Call geolocator for one address with lat/lon, adds option to set benchmark and vintage if not provided it will default to the most recent.
Description
Call geolocator for one address with lat/lon, adds option to set benchmark and vintage if not provided it will default to the most recent.
Usage
call_geolocator_latlon(lat, lon, benchmark, vintage)
Arguments
lat |
A numeric value |
lon |
A numeric value |
benchmark |
time period when a snapshot of address ranges was taken |
vintage |
census or survey that the address range relates to |
Value
A character string representing the Census block of the supplied lat/lon.
Author(s)
Josie Kressner, josie@transportfoundry.com
Mark Richards, Mark.Richards.002@gmail.com
Download a shapefile of the US coastline into R
Description
Download a shapefile of the US coastline into R
Usage
coastline(year = NULL, ...)
Arguments
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
Other water functions:
area_water()
,
linear_water()
Download a combined statistical areas shapefile into R
Description
Combined statistical areas are "two or more adjacent CBSAs that have significant employment interchanges." In turn, CSAs are composed of multiple metropolitan and/or micropolitan areas, and should not be compared with individual core-based statistical areas.
Usage
combined_statistical_areas(cb = FALSE, resolution = "500k", year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
resolution |
The resolution of the cartographic boundary file (if cb == TRUE). Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other metro area functions:
core_based_statistical_areas()
,
metro_divisions()
,
new_england()
,
urban_areas()
Download a congressional districts shapefile into R
Description
Description from the US Census Bureau (see link for source): Congressional districts are the 435 areas from which members are elected to the U.S. House of Representatives. After the apportionment of congressional seats among the states, which is based on decennial census population counts, each state with multiple seats is responsible for establishing congressional districts for the purpose of electing representatives. Each congressional district is to be as equal in population to all other congressional districts in a state as practicable. The boundaries and numbers shown for the congressional districts are those specified in the state laws or court orders establishing the districts within each state.
Usage
congressional_districts(
state = NULL,
cb = FALSE,
resolution = "500k",
year = NULL,
...
)
Arguments
state |
The two-digit FIPS code (string) of the state you want, or a
vector of codes if you want multiple states. Can also be state name
or state abbreviation. If |
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
resolution |
The resolution of the cartographic boundary file (if cb == TRUE). Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
Congressional districts for the 108th through 112th sessions were established by the states based on the result of the 2000 Census. Congressional districts for the 113th through 116th sessions were established by the states based on the result of the 2010 Census. Boundaries are effective until January of odd number years (for example, January 2015, January 2017, etc.), unless a state initiative or court ordered redistricting requires a change. All states established new congressional districts in 2011-2012, with the exception of the seven single member states (Alaska, Delaware, Montana, North Dakota, South Dakota, Vermont, and Wyoming).
The current default in tigris reflects boundaries for the 118th Congress, which is available for years 2022 and 2023. Older congressional district boundaries back to 2011 can be obtained by supplying the appropriate year. For the 119th Congress, use year = 2024
.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/congressional-dist.html
Other legislative district functions:
state_legislative_districts()
,
voting_districts()
Examples
## Not run:
library(tigris)
library(leaflet)
cd118 <- congressional_districts(cb = TRUE, resolution = '20m', year = 2022)
leaflet(cd118) %>%
addTiles() %>%
addPolygons()
## End(Not run)
Download a core-based statistical area shapefile into R
Description
Core-based statistical areas include both metropolitan areas and micropolitan areas. The US Census Bureau defines these areas as follows: "A metro area contains a core urban area of 50,000 or more population, and a micro area contains an urban core of at least 10,000 (but less than 50,000) population. Each metro or micro area consists of one or more counties and includes the counties containing the core urban area, as well as any adjacent counties that have a high degree of social and economic integration (as measured by commuting to work) with the urban core." Please see the link provided for more information
Usage
core_based_statistical_areas(cb = FALSE, resolution = "500k", year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
resolution |
The resolution of the cartographic boundary file (if cb == TRUE). Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/metro-micro.html
Other metro area functions:
combined_statistical_areas()
,
metro_divisions()
,
new_england()
,
urban_areas()
Download a US Counties shapefile into R, and optionally subset by state
Description
Description from the US Census Bureau (see link for source): The primary legal divisions of most states are termed counties. In Louisiana, these divisions are known as parishes. In Alaska, which has no counties, the equivalent entities are the organized boroughs, city and boroughs, municipalities, and census areas; the latter of which are delineated cooperatively for statistical purposes by the state of Alaska and the Census Bureau. In four states (Maryland, Missouri, Nevada, and Virginia), there are one or more incorporated places that are independent of any county organization and thus constitute primary divisions of their states. These incorporated places are known as independent cities and are treated as equivalent entities for purposes of data presentation. The District of Columbia and Guam have no primary divisions, and each area is considered an equivalent entity for purposes of data presentation. All of the counties in Connecticut and Rhode Island and nine counties in Massachusetts were dissolved as functioning governmental entities; however, the Census Bureau continues to present data for these historical entities in order to provide comparable geographic units at the county level of the geographic hierarchy for these states and represents them as nonfunctioning legal entities in data products. The Census Bureau treats the following entities as equivalents of counties for purposes of data presentation: municipios in Puerto Rico, districts and islands in American Samoa, municipalities in the Commonwealth of the Northern Mariana Islands, and islands in the U.S. Virgin Islands. Each county or statistically equivalent entity is assigned a three-character numeric Federal Information Processing Series (FIPS) code based on alphabetical sequence that is unique within state and an eight-digit National Standard feature identifier.
Usage
counties(state = NULL, cb = FALSE, resolution = "500k", year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want, or a vector of codes if you want multiple states. Can also be state name or state abbreviation. |
cb |
If cb is set to TRUE, download a generalized (1:500k) counties file. Defaults to FALSE (the most detailed TIGER file). |
resolution |
The resolution of the cartographic boundary file (if cb == TRUE). Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch4GARM.pdf
Other general area functions:
block_groups()
,
blocks()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
library(ggplot2)
me <- counties("Maine", cb = TRUE)
gg <- ggplot()
gg <- gg + geom_sf(data = me, color="black",
fill="white", size=0.25)
gg
## End(Not run)
Download a county subdivision shapefile into R
Description
From the US Census Bureau (see link for source, and more information): "All counties and statistically equivalent entities consist of one or more geographic units that the Bureau of the Census recognizes as county subdivisions. The two major types of county subdivisions are minor civil divisions(MCDs) and census county divisions (CCDs). A State has either MCDs or their statistical equivalents, or CCDs; it cannot contain both."
Usage
county_subdivisions(state, county = NULL, cb = FALSE, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also be state name or state abbreviation. |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch8GARM.pdf
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
or <- county_subdivisions('Oregon', c('Linn', 'Benton'))
plot(or$geometry)
## End(Not run)
Download a US Census divisions cartographic boundary shapefile into R
Description
Download a US Census divisions cartographic boundary shapefile into R
Usage
divisions(resolution = "500k", year = NULL, ...)
Arguments
resolution |
The resolution of the cartographic boundary file. Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
Other national cartographic boundary functions:
nation()
,
regions()
Examples
## Not run:
library(tigris)
library(leaflet)
divs <- divisions(resolution = '20m')
leaflet(divs) %>%
addTiles() %>%
addPolygons()
## End(Not run)
Erase water area from an input polygon dataset
Description
This function 'erases' water area from an input polygon dataset (typically a Census dataset). 'Erase' is defined in the traditional GIS sense as the removal of areas in an input layer from an erase layer, returning the modified input layer. A common use-case is to improve cartographic representation of locations where US Census polygons include more water area than desired (e.g. New York City, Seattle) or to support contiguity-based spatial analyses that might otherwise incorrectly assume that polygons across bodies of water are neighbors.
Usage
erase_water(input_sf, area_threshold = 0.75, year = NULL)
Arguments
input_sf |
An input sf object, ideally obtained with the tigris package or through tidycensus. |
area_threshold |
The percentile rank cutoff of water areas to use in the erase operation, ranked by size. Defaults to 0.75, representing the water areas in the 75th percentile and up (the largest 25 percent of areas). This value may need to be modified by the user to achieve optimal results for a given location. |
year |
The year to use for the water layer; defaults to 2020 unless the |
Details
The function works by identifying US counties that intersect the input polygon layer,
then requesting water polygons (using tigris::area_water()
) to be erased from
those input polygons. The area_threshold
parameter can be tuned to determine the
percentile ranking of bodies of water (by area) to use;
the default is a percentile ranking of 0.75, erasing the largest 25 percent of water
bodies in the region.
Analysts will ideally have transformed the input coordinate reference system (CRS) of their data to a projected CRS to improve performance; see https://walker-data.com/census-r/census-geographic-data-and-applications-in-r.html#coordinate-reference-systems for more information on how to perform CRS transformations. Analysts should also use this function with caution; the function may generate sliver polygons or irregular geometries in the output layer, especially if the input sf object was not obtained with the tigris package. Also, the operation may be quite slow for large input areas.
Value
An output sf object representing the polygons in input_sf
with water areas erased.
Examples
## Not run:
library(tigris)
library(sf)
options(tigris_use_cache = TRUE)
king_tracts <- tracts(state = "WA", county = "King", year = 2020)
# CRS: NAD 1983 / Washington North (State Plane)
king_erased <- king_tracts %>%
st_transform(32148) %>%
erase_water(area_threshold = 0.9)
plot(king_erased$geometry)
## End(Not run)
Filter a places
Spatial object for only those places matching the
contents of the place
vector.
Description
Filter a places
Spatial object for only those places matching the
contents of the place
vector.
Usage
filter_place(places, place)
Arguments
places |
object returned from a call to |
place |
a vector of full place names. The function performs the comparison in a case-insensitive manner. |
Examples
## Not run:
places("Maine") %>% filter_place("berwick")
## End(Not run)
Filter a states
Spatial object for only those states matching the
contents of the state
vector.
Description
Filter a states
Spatial object for only those states matching the
contents of the state
vector.
Usage
filter_state(states, state)
Arguments
states |
object returned from a call to |
state |
a vector of full state names. The function performs the comparison in a case-insensitive manner. |
Examples
## Not run:
states() %>% filter_state("south")
## End(Not run)
Dataset with FIPS codes for US states and counties
Description
Built-in dataset for use with the lookup_code
function.
To access the data directly, issue the command data(fips_codes)
.
-
county
: County name, title-case -
county_code
: County code. (3-digit, 0-padded, character) -
state
: Upper-case abbreviation of state -
state_code
: State FIPS code (2-digit, 0-padded, character) -
state_name
: Title-case name of state
Usage
data(fips_codes)
Format
A data frame with 3,256 rows and 5 variables
Details
Dataset with FIPS codes for US states and counties
Built-in dataset for use with the lookup_code
function.
To access the data directly, issue the command data(fips_codes)
.
Note
Last updated 2023-05-18
Easily merge a data frame to a spatial data frame
Description
This function should be considered deprecated. Please update your workflow to use sf objects and dplyr's *_join()
family of functions instead.
Usage
geo_join(spatial_data, data_frame, by_sp, by_df, by = NULL, how = "left")
Arguments
spatial_data |
A spatial data frame to which you want to merge data. |
data_frame |
A regular data frame that you want to merge to your spatial data. |
by_sp |
The column name you'll use for the merge from your spatial data frame. |
by_df |
The column name you'll use for the merge from your regular data frame. |
by |
(optional) If a named argument is supplied to the by parameter, geo_join will assume that the join columns in the spatial data and data frame share the same name. |
how |
The type of join you'd like to perform. The default, 'left', keeps all rows in the spatial data frame, and returns NA for unmatched rows. The alternative, 'inner', retains only those rows in the spatial data frame that match rows from the target data frame. |
Value
a joined spatial/data frame object
Examples
## Not run:
library(rnaturalearth)
library(WDI)
library(tigris)
dat <- WDI(country = "all", indicator = "SP.DYN.LE00.IN", start = 2012, end = 2012)
dat$SP.DYN.LE00.IN <- round(dat$SP.DYN.LE00.IN, 1)
countries <- ne_countries()
countries2 <- geo_join(countries, dat, 'iso_a2', 'iso2c')
nrow(countries2)
## [1] 177
countries3 <- geo_join(countries, dat, 'iso_a2', 'iso2c', how = 'inner')
nrow(countries3)
## [1] 169
## End(Not run)
Find places matching a term in a places
object
Description
This is just shorthand for
grep(term, list_places(places), value=TRUE, ignore.case=TRUE)
Usage
grep_place(places, term)
Arguments
places |
object returned from a call to |
term |
equivalent to the |
Examples
## Not run:
places("Maine") %>% grep_place("south")
## End(Not run)
Find states matching a term in a state
object
Description
This is just shorthand for
grep(term, list_states(states), value=TRUE, ignore.case=TRUE)
Usage
grep_state(states, term)
Arguments
states |
object returned from a call to |
term |
equivalent to the |
Examples
## Not run:
states() %>% grep_state("north")
## End(Not run)
Returns TRUE
if obj
has a tigris
attribute
Description
It's unlikely that said object was not created by this package
Usage
is_tigris(obj)
Arguments
obj |
R object to test |
Value
TRUE
if obj
was made by this package
Download a point or area landmarks shapefile into R
Description
Description from the US Census Bureau: "The Census Bureau includes landmarks in the MAF/TIGER database (MTDB) for locating special features and to help enumerators during field operations. Some of the more common landmark types include area landmarks such as airports, cemeteries, parks, and educational facilities and point landmarks such as schools and churches."
Usage
landmarks(state, type = "point", year = NULL, ...)
Arguments
state |
The state for which you'd like to download the landmarks |
type |
Whether you would like to download point landmarks ( |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
The Census Bureau adds landmark features to the database on an as-needed basis and makes no attempt to ensure that all instances of a particular feature were included. The absence of a landmark such as a hospital or prison does not mean that the living quarters associated with that landmark were excluded from the 2010 Census enumeration. The landmarks were not used as the basis for building or maintaining the address list used to conduct the 2010 Census.
Area landmark and area water features can overlap; for example, a park or other special land-use feature may include a lake or pond. In this case, the polygon covered by the lake or pond belongs to a water feature and a park landmark feature. Other kinds of landmarks can overlap as well. Area landmarks can contain point landmarks, but these features are not linked in the TIGER/Line Shapefiles.
Landmarks may be identified by a MAF/TIGER feature class code only and may not have a name. Each landmark has a unique area landmark identifier (AREAID) or point landmark identifier (POINTID) value.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc_Ch3.pdf
Download an linear water shapefile into R
Description
From the US Census Bureau: "The linear hydrography shapefile contains all linear features with "H" (Hydrography) type MTFCCs in the MAF/TIGER database by county. The shapefiles are provided at a county geographic extent and in linear elemental feature geometry. The linear hydrography shapefile includes streams/rivers, braided streams, canals, ditches, artificial paths, and aqueducts. A linear hydrography feature may include edges with both perennial and intermittent persistence."
Usage
linear_water(state, county, year = NULL, ...)
Arguments
state |
The two-digit FIPS code of the state of the county you'd like to download the water features for. Can also be state name or abbreviation (case-insensitive). |
county |
The three-digit FIPS code of the county you'd like the water features for. Can also be a county name. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other water functions:
area_water()
,
coastline()
Examples
## Not run:
library(tigris)
dallas_water <- linear_water("TX", "Dallas")
plot(dallas_water$geometry)
## End(Not run)
Return a data frame of county names & FIPS codes for a given state
Description
Return a data frame of county names & FIPS codes for a given state
Usage
list_counties(state)
Arguments
state |
String representing the state you'd like to look up. Accepts state names (spelled correctly), e.g. "Texas", or postal codes, e.g. "TX". Can be lower-case. |
Value
data frame of county name and FIPS code or NULL if invalid state
Return a list of all the places in a places
object
Description
Return a list of all the places in a places
object
Usage
list_places(places, sorted = TRUE)
Arguments
places |
object returned from a call to |
sorted |
return the list sorted or in the order found in the shapefile? |
Examples
## Not run:
places("Maine") %>% list_places()
## End(Not run)
Return a list of all the states in a state
object
Description
Return a list of all the states in a state
object
Usage
list_states(states, sorted = TRUE)
Arguments
states |
object returned from a call to |
sorted |
return the list sorted or in the order found in the shapefile? |
Examples
## Not run:
states() %>% list_states()
## End(Not run)
Helper function to download Census data
Description
Helper function to download Census data
Usage
load_tiger(
url,
refresh = getOption("tigris_refresh", FALSE),
tigris_type = NULL,
class = getOption("tigris_class", "sf"),
progress_bar = TRUE,
keep_zipped_shapefile = FALSE,
filter_by = NULL,
protocol = getOption("tigris_protocol", "http"),
timeout = 1800
)
Arguments
url |
URL for zipped shapefile in TIGER database (constructed in calling function). |
refresh |
Whether to re-download shapefiles if cached. Defaults to value of the global option "tigris_refresh" if that option is, and FALSE if not. This will override the behavior set in "tigris_refresh" option if a value (TRUE or FALSE) is provided. |
tigris_type |
Added as an attribute to return object (used internally). |
class |
Class of return object. Must be one of "sf" (the default) or "sp". |
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. |
filter_by |
Geometry used to filter the output returned by the function. Can be an sf object, an object of class |
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. Defaults to 300 (5 minutes) to handle large files. |
Value
sf or sp data frame
Documentation Template for Functions that Utilize load_tiger
Description
Documentation Template for Functions that Utilize load_tiger
Arguments
... |
arguments to be passed to internal function |
year |
the data year; defaults to 2024 |
Details
This documentation is inherited by tigris
functions that wrap load_tiger
.
Include the following in function documentation:
@inheritParams load_tiger_doc_template
@inheritSection load_tiger_doc_template Additional Arguments
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
Look up state and county codes
Description
Function to look up the FIPS codes for states and optionally counties you'd l ike to load data for. As the package functions require the codes to return the data correctly, this function makes it easy to find the codes that you need.
Usage
lookup_code(state, county = NULL)
Arguments
state |
String representing the state you'd like to look up. Accepts state names (spelled correctly), e.g. "Texas", or postal codes, e.g. "TX". Can be lower-case. |
county |
The name of the county you'll like to search for. T he state that the county is located in must be supplied for this to work, as there are multiple counties with the same names across states. Can be lower-case. |
Value
character string with an explanation of state/county FIPS codes
Examples
## Not run:
lookup_code("me")
## [1] "The code for Maine is '23'."
lookup_code("Maine")
## [1] "The code for Maine is '23'."
lookup_code("23")
## [1] "The code for Maine is '23'."
lookup_code(23)
## [1] "The code for Maine is '23'."
lookup_code("me", "york")
## [1] "The code for Maine is '23' and the code for York County is '031'."
lookup_code("Maine", "York County")
## [1] "The code for Maine is '23' and the code for York County is '031'."
## End(Not run)
Download a metropolitan divisions shapefile into R.
Description
Metropolitan divisions are subdivisions of metropolitan areas with population of at least 2.5 million. Please note: not all metropolitan areas have metropolitan divisions.
Usage
metro_divisions(year = NULL, ...)
Arguments
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other metro area functions:
combined_statistical_areas()
,
core_based_statistical_areas()
,
new_england()
,
urban_areas()
Download the Military Installation National Shapefile into R
Description
Description from the US Census Bureau: "The Census Bureau includes landmarks such as military installations in the MAF/TIGER database for locating special features and to help enumerators during field operations. The Census Bureau adds landmark features to the database on an as-needed basis and does not attempt to ensure that all instances of a particular feature are included. For additional information about area landmarks, please see Section 3.12, Landmarks (Area and Point)."
Usage
military(year = NULL, ...)
Arguments
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
This file does not include the three point landmarks identified as military installation features in the MAF/TIGER database. These point landmarks are included in the point landmark shapefile. Although almost all military installations have assigned 8-character National Standard (GNIS) codes, the Census Bureau has not loaded most of this data into the MAF/TIGER database. The 2020 military shapefiles contain few values in the ANSICODE field.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc_Ch3.pdf
Download a US national boundary shapefile into R
Description
Download a US national boundary shapefile into R
Usage
nation(resolution = "5m", year = NULL, ...)
Arguments
resolution |
The resolution of the cartographic boundary file. Defaults to '5m'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
Other national cartographic boundary functions:
divisions()
,
regions()
Examples
## Not run:
library(tigris)
library(leaflet)
boundary <- nation(resolution = '20m')
leaflet(boundary) %>%
addTiles() %>%
addPolygons()
## End(Not run)
Download an American Indian / Alaska Native / Native Hawaiian Areas shapefile into R.
Description
Description from the Census Bureau: "This shapefile contain both legal and statistical American Indian, Alaska Native, and Native Hawaiian entities for which the Census Bureau publishes data. The legal entities consist of federally recognized American Indian reservations and off-reservation trust land areas, state-recognized American Indian reservations, and Hawaiian home lands (HHLs)." For more information, please see the link provided.
Usage
native_areas(cb = FALSE, year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch5GARM.pdf
Other native/tribal geometries functions:
alaska_native_regional_corporations()
,
tribal_block_groups()
,
tribal_census_tracts()
,
tribal_subdivisions_national()
Examples
## Not run:
library(tigris)
library(ggplot2)
library(ggthemes)
nat <- native_areas(cb = TRUE)
gg <- ggplot()
gg <- gg + geom_sf(data = nat, color="black", fill="white", size=0.25)
gg <- gg + coord_sf(xlim=c(-179.1506, -129.9795), # alaska
ylim=c(51.2097, 71.4410))
gg <- gg + theme_map()
gg
## End(Not run)
Download a New England City and Town Area shapefile into R
Description
From the US Census Bureau (see link for source): "In New England (Connecticut, Maine, Massachusetts, New Hampshire, Rhode Island, and Vermont), the OMB has defined an alternative county subdivision (generally city and town) based definition of CBSAs known as New England city and town areas (NECTAs). NECTAs are defined using the same criteria as metropolitan and micropolitan statistical areas and are identified as either metropolitan or micropolitan, based, respectively, on the presence of either an urbanized area of 50,000 or more inhabitants or an urban cluster of at least 10,000 and less than 50,000 inhabitants." Combined NECTAs, or CNECTAs, are two or more NECTAs that have significant employment interchange, like Combined Statistical Areas; NECTA divisions are subdivisions of NECTAs.
Usage
new_england(type = "necta", cb = FALSE, year = NULL, ...)
Arguments
type |
Specify whether to download the New England City and Town Areas file ( |
cb |
If cb is set to TRUE, download a generalized (1:500k)
cartographic boundary file. Defaults to FALSE (the most detailed
TIGER/Line file). Only available when |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other metro area functions:
combined_statistical_areas()
,
core_based_statistical_areas()
,
metro_divisions()
,
urban_areas()
Examples
## Not run:
library(tigris)
ne <- new_england(cb = TRUE)
plot(ne$geometry)
## End(Not run)
Download Shapefiles which include both incorporated places (legal entities) and census designated places (statistical entities) into R
Description
An incorporated place provides governmental functions for a concentration of people. Incorporated places may extend across county and county subdivision boundaries, but never across state boundaries. An incorporated place usually is a city, town, village, or borough, but can have other legal descriptions. CDPs are the statistical counterparts of incorporated places. CDPs are settled concentrations of population that are identifiable by name but not legally incorporated under the laws of the state in which the CDPs are located. For more information, read appropriate section on "Places" for the correct vintage (year) of your data in the TIGER/Line Shapefiles and TIGER/Line Files Technical Documentation available as of this writing here: https://www.census.gov/programs-surveys/geography/technical-documentation/complete-technical-documentation/tiger-geo-line.html.
Usage
places(state = NULL, cb = FALSE, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also
be state name or state abbreviation. When |
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch9GARM.pdf
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
pumas()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Download a national primary roads shapefile into R
Description
From the Census Bureau: "Primary roads are generally divided, limited-access highways within the Federal interstate highway system or under state management. These highways are distinguished by the presence of interchanges and are accessible by ramps and may include some toll highways."
Usage
primary_roads(year = NULL, ...)
Arguments
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Value
an sf object with columns
-
LINEARID
: a unique line feature identifier (source) -
FULLNAME
: display name (source) -
RTTYP
: describes the types of roads used (source). Possible values are:"C": county
"I": interstate
"M": common name
"O": other
"S": state regonized
"U": U.S.
-
MTFCC
: 5-digit geographic code assignment (see annual assignments)
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other transportation functions:
address_ranges()
,
primary_secondary_roads()
,
rails()
,
roads()
Examples
## Not run:
library(tigris)
rds <- primary_roads()
plot(rds$geometry)
## End(Not run)
Download a primary & secondary roads shapefile into R
Description
From the Census Bureau: "Primary roads are generally divided, limited-access highways within the Federal interstate highway system or under state management. These highways are distinguished by the presence of interchanges and are accessible by ramps and may include some toll highways. Secondary roads are main arteries, usually in the U.S. highway, state highway, or county highway system. These roads have one or more lanes of traffic in each direction, may or may not be divided, and usually have at-grade intersections with many other roads and driveways.
Usage
primary_secondary_roads(state, year = NULL, ...)
Arguments
state |
The two-digit FIPS code of the state of the county you'd like to download the roads for. Can also be state name or abbreviation (case-insensitive). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Value
an sf object with columns
-
LINEARID
: a unique line feature identifier (source) -
FULLNAME
: display name (source) -
RTTYP
: describes the types of roads used (source). Possible values are:"C": county
"I": interstate
"M": common name
"O": other
"S": state regonized
"U": U.S.
-
MTFCC
: 5-digit geographic code assignment (see annual assignments)
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other transportation functions:
address_ranges()
,
primary_roads()
,
rails()
,
roads()
Examples
## Not run:
library(tigris)
rds <- primary_secondary_roads()
plot(rds$geometry)
## End(Not run)
Download a Public Use Microdata Area (PUMA) shapefile into R
Description
Public use microdata areas (PUMAs) are decennial census areas that have been defined for the tabulation and dissemination of Public Use Microdata Sample (PUMS) data, American Community Survey (ACS) data, and ACS period estimates. For the 2010 Census, the State Data Centers (SDCs) in each state, the District of Columbia, and the Commonwealth of Puerto Rico were given the opportunity to delineate PUMAs within their state or statistically equivalent entity. All PUMAs must nest within states and have a minimum population threshold of 100,000 persons. 2010 PUMAs were built on census tracts and cover the entirety of the United States, Puerto Rico, Guam, and the U.S. Virgin Islands. Because they do not meet the minimum population requirement, the Commonwealth of the Northern Mariana Islands and American Samoa do not contain any 2010 PUMAs.
Usage
pumas(state = NULL, cb = FALSE, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also
be state name or state abbreviation. When |
cb |
If cb is set to TRUE, download a generalized (1:500k) states file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/pumas.html
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
school_districts()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
us_states <- unique(fips_codes$state)[1:51]
continental_states <- us_states[!us_states %in% c("AK", "HI")]
pumas_list <- lapply(continental_states, function(x) {
pumas(state = x, cb = TRUE, year = 2017)
})
us_pumas <- rbind_tigris(pumas_list)
plot(us_pumas$geometry)
## End(Not run)
Download a national rails shapefile into R
Description
National dataset for US railroads, including carlines, streetcars, monorails, mass transit, cog rail, incline rail, and trams.
Usage
rails(year = NULL, ...)
Arguments
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other transportation functions:
address_ranges()
,
primary_roads()
,
primary_secondary_roads()
,
roads()
Examples
## Not run:
library(tigris)
rls <- rails()
plot(rls$geometry)
## End(Not run)
Row-bind tigris
Spatial objects
Description
If multiple school district types are rbound, coerces to "sdall" and does it
Usage
rbind_tigris(...)
Arguments
... |
individual (optionally names) |
Value
one combined Spatial object
Examples
## Not run:
library(tigris)
me_ctys <- list_counties("me")
aw <- lapply(me_ctys$county_code[1:3], function(x) {
area_water("Maine", x)
}) %>%
rbind_tigris()
## End(Not run)
Download a US regions cartographic boundary shapefile into R
Description
Download a US regions cartographic boundary shapefile into R
Usage
regions(resolution = "500k", year = NULL, ...)
Arguments
resolution |
The resolution of the cartographic boundary file. Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
Other national cartographic boundary functions:
divisions()
,
nation()
Examples
## Not run:
library(tigris)
library(leaflet)
us_regions <- regions(resolution = '20m')
leaflet(us_regions) %>%
addTiles() %>%
addPolygons()
## End(Not run)
Download a roads shapefile into R
Description
From the Census Bureau: "The content of the all roads shapefile includes primary roads, secondary roads, local neighborhood roads, rural roads, city streets, vehicular trails (4WD), ramps, service drives, walkways, stairways, alleys, and private roads."
Usage
roads(state, county, year = NULL, ...)
Arguments
state |
A character vector of the two-digit FIPS code of the state of the county you'd like to download the roads for. Can also be state name or abbreviation (case-insensitive). |
county |
A character vector of the three-digit FIPS code of the county you'd like the roads for. Can also be a county name. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Value
an sf object with columns
-
LINEARID
: a unique line feature identifier (source) -
FULLNAME
: display name (source) -
RTTYP
: describes the types of roads used (source). Possible values are:"C": county
"I": interstate
"M": common name
"O": other
"S": state regonized
"U": U.S.
-
MTFCC
: 5-digit geographic code assignment (see annual assignments)
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other transportation functions:
address_ranges()
,
primary_roads()
,
primary_secondary_roads()
,
rails()
Examples
## Not run:
library(tigris)
library(ggplot2)
library(ggthemes)
roads <- roads("Maine", "031")
gg <- ggplot()
gg <- gg + geom_sf(data = roads,
color="black", fill="white", size=0.25)
gg <- gg + theme_map()
gg
## End(Not run)
Download a school district shapefile into R
Description
From the US Census Bureau (see link for source): School Districts are single-purpose administrative units within which local officials provide public educational services for the area's residents. The Census Bureau obtains school district boundaries, names, local education agency codes, grade ranges, and school district levels biennially from state education officials. The Census Bureau collects this information for the primary purpose of providing the U.S. Department of Education with annual estimates of the number of children in poverty within each school district, county, and state. This information serves as the basis for the Department of Education to determine the annual allocation of Title I funding to states and school districts.
Usage
school_districts(state = NULL, type = "unified", cb = FALSE, year = NULL, ...)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also
be state name or state abbreviation. When |
type |
Specify whether you want to return a unified school district (the default, |
cb |
if TRUE, download a generalized (1:500k) school districts file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
The Census Bureau creates pseudo-unified school districts for areas in which unified school districts do not exist. Additionally, elementary and secondary school districts do not exist in all states. Please see the link for more information on how the Census Bureau creates the school district shapefiles.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
states()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
library(leaflet)
schools <- school_districts("Maine")
leaflet(schools) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5)
## End(Not run)
Shift and rescale Alaska, Hawaii, and Puerto Rico in a US-wide sf object
Description
This function will shift and optionally rescale a US dataset for thematic mapping of Alaska,
Hawaii, and Puerto Rico with respect to the continental United States. Features in the continental
United States will have their CRS transformed to USA Contiguous Albers Equal Area Conic ('ESRI:102003').
Alaska, Hawaii, and Puerto Rico features are transformed to appropriate coordinate systems for those areas,
then shifted and optionally re-scaled before being assigned the 'ESRI:102003' CRS. Options for users
include preserve_area
which allows for preservation of the area of AK/HI/PR relative to the
continental US if desired, and two possible arrangements which are specified with position = "below"
or position = "outside"
Usage
shift_geometry(
input_sf,
geoid_column = NULL,
preserve_area = FALSE,
position = c("below", "outside")
)
Arguments
input_sf |
The input sf dataset |
geoid_column |
The GEOID column of the dataset that contains a state ID. If used, will speed up
processing and avoid spatial overlay to infer locations. Defaults to |
preserve_area |
If TRUE, the areas of Alaska/Hawaii/Puerto Rico relative to the continental US will be preserved. Defaults to FALSE where Alaska is proportionally smaller and Hawaii/Puerto Rico are proportionally larger. |
position |
One of |
Details
shift_geometry()
, while designed for use with objects from the tigris package, will work with any US
dataset. If aligning datasets from multiple sources, you must take care to ensure that your options
specified in preserve_area
and position
are identical across layers. Otherwise your layers
will not align correctly.
The function is also designed to work exclusively with features in the continental United States,
Alaska, Hawaii, and Puerto Rico. If your dataset includes features outside these areas (e.g. other
US territories or other countries), you may get unworkable results. It is advisable to filter out
those features before using shift_geometry()
.
Work on this function is inspired by and adapts some code from Claus Wilke's book Fundamentals of Data Visualization (https://clauswilke.com/dataviz/geospatial-data.html); Bob Rudis's albersusa R package (https://github.com/hrbrmstr/albersusa); and the ggcart R package (https://uncoast-unconf.github.io/ggcart/).
Value
The input sf object with transformed geometry
Examples
## Not run:
# Shift and rescale AK/HI/PR for thematic mapping
library(tigris)
library(tidycensus)
library(tidyverse)
us_states <- states(cb = TRUE, resolution = "20m") %>%
shift_geometry()
# Shift but preserve area
us_states_eqarea <- states(cb = TRUE, resolution = "20m") %>%
shift_geometry(preserve_area = TRUE)
# Shift and rescale but position AK/HI/PR outside the continental US rather than below
us_states_outside <- states(cb = TRUE, resolution = "20m") %>%
shift_geometry(position = "outside")
# Shift a dataset obtained outside tigris and make a map
income_by_metro <- get_acs(
geography = "cbsa",
variables = "B01002_001",
geometry = TRUE
) %>%
shift_geometry()
ggplot() +
geom_sf(data = income_by_metro, aes(fill = estimate), color = NA) +
geom_sf(data = us_states, fill = NA, color = "black", size = 0.1) +
scale_fill_viridis_c() +
theme_void(base_size = 16) +
labs(title = "Median age by CBSA, 2015-2019 ACS",
fill = "ACS estimate ",
caption = "Note: Alaska, Hawaii, and Puerto Rico are shifted and not to scale.") +
theme(plot.title = element_text(hjust = 0.5))
## End(Not run)
Download a state legislative districts shapefile into R - upper or lower
Description
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.
Usage
state_legislative_districts(
state = NULL,
house = "upper",
cb = FALSE,
year = NULL,
...
)
Arguments
state |
The two-digit FIPS code (string) of the state. Can also be state
name or abbreviation (case-insensitive). When |
house |
Specify here whether you want boundaries for the |
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/state-legis-dist.html
Other legislative district functions:
congressional_districts()
,
voting_districts()
Examples
## Not run:
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)
## End(Not run)
Download shapefile for all states into R
Description
States and Equivalent Entities are the primary governmental divisions of the United States. In addition to the 50 states, the Census Bureau treats the District of Columbia, Puerto Rico, American Samoa, the Commonwealth of the Northern Mariana Islands, Guam, and the U.S. Virgin Islands as the statistical equivalents of states for the purpose of data presentation.
Usage
states(cb = FALSE, resolution = "500k", year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) states file. Defaults to FALSE (the most detailed TIGER/Line file) |
resolution |
The resolution of the cartographic boundary file (if cb == TRUE). Defaults to '500k'; options include '5m' (1:5 million) and '20m' (1:20 million). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch4GARM.pdf
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
tracts()
,
zctas()
Examples
## Not run:
library(tigris)
library(leaflet)
states <- states(cb = TRUE)
leaflet(states) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5) %>%
setView(-98.5795, 39.8282, zoom=3)
## End(Not run)
tigris exported operators
Description
tigris exported operators
Pipe operator
Set the cache directory to store shapefiles with tigris
Description
By default, tigris uses the rappdirs package to determine a suitable location to store shapefiles on the user's computer. However, it is possible that the user would want to store shapefiles in a custom location. This function allows users to set the cache directory, and stores the result in the user's .Renviron so that tigris will remember the location.
Windows users: please note that you'll need to use double-backslashes or forward slashes when specifying your cache directory's path in R.
Usage
tigris_cache_dir(path)
Arguments
path |
The full path to the desired cache directory |
Examples
## Not run:
# Set the cache directory
tigris_cache_dir('PATH TO MY NEW CACHE DIRECTORY')
# Check to see if it has been set correctly
Sys.getenv('TIGRIS_CACHE_DIR')
## End(Not run)
Get the type of tigris
object obj
is
Description
Get the type of tigris
object obj
is
Usage
tigris_type(obj)
Arguments
obj |
R object to test |
Value
character vector containing the tigris
type of obj
or NA
if obj
is not a code tigris
object
Download a Census tracts shapefile into R, and optionally subset by county
Description
Description from the US Census Bureau (see link for source): Census Tracts are small, relatively permanent statistical subdivisions of a county or equivalent entity that are updated by local participants prior to each decennial census as part of the Census Bureau's Participant Statistical Areas Program. The Census Bureau delineates census tracts in situations where no local participant existed or where state, local, or tribal governments declined to participate. The primary purpose of census tracts is to provide a stable set of geographic units for the presentation of statistical data.
Usage
tracts(
state = NULL,
county = NULL,
cb = FALSE,
resolution = "500k",
year = NULL,
...
)
Arguments
state |
The two-digit FIPS code (string) of the state you want. Can also
be state name or state abbreviation. When |
county |
The three-digit FIPS code (string) of the county you'd like to subset for, or a vector of FIPS codes if you desire multiple counties. Can also be a county name or vector of names. |
cb |
If cb is set to TRUE, download a generalized (1:500k) tracts file. Defaults to FALSE (the most detailed TIGER/Line file) |
resolution |
The resolution of the cartographic boundary file (if using cb = TRUE). Defaults to '500k'; the other option is '5m' (1:5 million). Resolution of '5m' is #' only available for the national Census tract file for years 2022 and later. |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
Census tracts generally have a population size between 1,200 and 8,000 people, with an optimum size of 4,000 people. A census tract usually covers a contiguous area; however, the spatial size of census tracts varies widely depending on the density of settlement. Census tract boundaries are delineated with the intention of being maintained over a long time so that statistical comparisons can be made from census to census. Census tracts occasionally are split due to population growth or merged as a result of substantial population decline.
Census tract boundaries generally follow visible and identifiable features. They may follow nonvisible legal boundaries, such as minor civil division (MCD) or incorporated place boundaries in some states and situations, to allow for census-tract-to-governmental-unit relationships where the governmental boundaries tend to remain unchanged between censuses. State and county boundaries always are census tract boundaries in the standard census geographic hierarchy.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch10GARM.pdf
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
zctas()
Examples
## Not run:
library(tigris)
library(leaflet)
tarrant <- tracts("TX", "Tarrant", cb = TRUE)
leaflet(tarrant) %>%
addTiles() %>%
addPolygons(popup = ~NAME)
## End(Not run)
Download a Tribal block groups shapefile into R.
Description
From the US Census Bureau: "Tribal block groups are subdivisions of a tribal census tract. Tribal block groups were defined by federally recognized tribal government officials in the Census Bureau's Tribal Statistical Areas Program (TSAP) for the 2010 Census. If a tribal government declined to participate in TSAP, the Census Bureau delineated tribal block groups on the American Indian reservation and/or off-reservation trust land (ORTL). Tribal block groups are intended to generally contain between 600 and 3000 persons or between 240 and 1200 housing units. Many American Indian reservations and ORTLs have less than the minimum population thresholds for more than one tribal block group and in those cases one tribal block group was delineated that covers the entire American Indian reservation and/or ORTL. Unlike standard block groups, the cluster of blocks that comprises each tribal block group will not necessarily begin with the same first number of their 4-character census block number, but may contain blocks from several different standard census block groups." For more information, please see the link provided.
Usage
tribal_block_groups(cb = FALSE, year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch5GARM.pdf
Other native/tribal geometries functions:
alaska_native_regional_corporations()
,
native_areas()
,
tribal_census_tracts()
,
tribal_subdivisions_national()
Examples
## Not run:
library(tigris)
library(leaflet)
trib <- tribal_block_groups()
leaflet(trib) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5)
## End(Not run)
Download a Tribal Census tract shapefile into R.
Description
From the US Census Bureau: "Tribal census tracts are relatively small statistical subdivisions of an American Indian reservation and/or off-reservation trust land (ORTL) and were defined by federally recognized tribal government officials in the Census Bureau's Tribal Statistical Areas Program (TSAP) for the 2010 Census. If a tribal government declined to participate in TSAP, the Census Bureau delineated tribal census tracts on the American Indian reservation and/or ORTL. Tribal census tracts are conceptually similar and equivalent to standard census tracts. Unlike standard census tracts, however, tribal census tracts may cross state, county, and standard census tract boundaries." For more information, please view the link provided.
Usage
tribal_census_tracts(cb = FALSE, year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch5GARM.pdf
Other native/tribal geometries functions:
alaska_native_regional_corporations()
,
native_areas()
,
tribal_block_groups()
,
tribal_subdivisions_national()
Examples
## Not run:
library(tigris)
library(leaflet)
trib <- tribal_census_tracts()
leaflet(trib) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5)
## End(Not run)
Download an American Indian Tribal Subdivision National shapefile into R.
Description
Definition from the US Census Bureau: "American Indian Tribal Subdivisions (AITS) are legally defined administrative subdivisions of federally recognized American Indian reservations and/or off-reservation trust lands or Oklahoma tribal statistical areas (OTSAs)." For more information, please see the link provided.
Usage
tribal_subdivisions_national(cb = FALSE, year = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) file. Defaults to FALSE (the most detailed TIGER/Line file) |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch5GARM.pdf
Other native/tribal geometries functions:
alaska_native_regional_corporations()
,
native_areas()
,
tribal_block_groups()
,
tribal_census_tracts()
Examples
## Not run:
library(tigris)
library(leaflet)
trib <- tribal_subdivisions_national()
leaflet(trib) %>%
addProviderTiles("CartoDB.Positron") %>%
addPolygons(fillColor = "white",
color = "black",
weight = 0.5)
## End(Not run)
Download an urban areas shapefile into R
Description
Urban areas include both "urbanized areas," which are densely developed areas with a population of at least 50,000, and "urban clusters," which have a population of greater than 2,500 but less than 50,000. For more information, please see the link provided.
Usage
urban_areas(cb = FALSE, year = NULL, criteria = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
year |
the data year; defaults to 2024 |
criteria |
If set to "2020" and the year is 2020, will download the new 2020 urban areas criteria. Not available for cartographic boundary shapefiles / other years at the moment. |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/urban-rural.html
Other metro area functions:
combined_statistical_areas()
,
core_based_statistical_areas()
,
metro_divisions()
,
new_england()
Download a voting districts shapefile into R
Description
Obtain feature geometry for 2020 voting districts, which align with voting districts for the 2020 PL-94171 redistricting data from the US Census Bureau.
Usage
voting_districts(state = NULL, county = NULL, cb = FALSE, year = 2020, ...)
Arguments
state |
The state for which you'd like to retrieve data. Can be a state name,
state abbreviation, or FIPS code. When |
county |
The county for which you are requesting data. Can be a county name or
FIPS code. If |
cb |
If cb is set to TRUE, download a generalized (1:500k) cartographic boundary file. Defaults to FALSE (the most detailed TIGER/Line file). |
year |
the data year; defaults to 2024 |
... |
arguments to be passed to internal function |
Details
The US Census Bureau describes voting districts as follows: Voting district (VTD) is a generic term adopted by the Bureau of the Census to include the wide variety of small polling areas, such as election districts, precincts, or wards, that State and local governments create for the purpose of administering elections. Some States also use groupings of these entities to define their State and local legislative districts, as well as the districts they define for election of members to the U.S. House of Representatives. In a nationwide cooperative program for the 1980 census, the Census Bureau gave States the opportunity to request use of these election precinct boundaries as the boundaries of #' census enumeration districts (EDs) or, in some areas, census blocks.
Support for voting districts in tigris 1.5 and higher is aligned with the 2020 PL redistricting
data. The argument cb = FALSE
retrieves voting districts from the TIGER/Line PL
shapefiles. A generalized version from the cartographic boundary dataset is available with the
argument cb = TRUE
.
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www2.census.gov/geo/pdfs/reference/GARM/Ch14GARM.pdf
Other legislative district functions:
congressional_districts()
,
state_legislative_districts()
Examples
## Not run: #'
library(tigris)
ia <- voting_districts("Iowa")
plot(ia$geometry)
## End(Not run)
Download a Zip Code Tabulation Area (ZCTA) shapefile into R
Description
ZIP Code Tabulation Areas (ZCTAs) are generalized areal representations of United States Postal Service (USPS) ZIP Code service areas. Please see the link provided for information on how the Census Bureau creates ZCTAs, and for important information on the differences between ZCTAs and ZIP Codes.
Usage
zctas(cb = FALSE, starts_with = NULL, year = NULL, state = NULL, ...)
Arguments
cb |
If cb is set to TRUE, download a generalized (1:500k) ZCTA file. Defaults to FALSE (the most detailed TIGER/Line file). A warning: the detailed TIGER/Line ZCTA file is massive (around 502MB unzipped), and the generalized version is also large (64MB zipped). Be prepared for this especially if you have a slower internet connection. |
starts_with |
Character vector specifying the beginning digits of the
ZCTAs you want to return. For example, supplying the argument
|
year |
the data year; defaults to 2024 |
state |
the state for which you are requesting data; only available for 2000 (TIGER/Line and CB shapefiles) and 2010 (TIGER/Line shapefiles only) |
... |
arguments to be passed to internal function |
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 toFALSE
, do not display download progress bar (helpful for R Markdown documents). Defaults toTRUE
. -
keep_zipped_shapefile
If set toTRUE
, do not delete zipped shapefile (stored in temporary directory orTIGRIS_CACHE_DIR
depending on the configuration of global option"tigris_use_cache"
). Defaults toFALSE
. -
refresh
Whether to re-download cached shapefiles (TRUE
orFALSE
) . The default is eitherFALSE
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 classbbox
, or a length-4 vector of formatc(xmin, ymin, xmax, ymax)
that can be converted to a bbox. Geometries that intersect the input tofilter_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.
See Also
https://www.census.gov/programs-surveys/geography/guidance/geo-areas/zctas.html
Other general area functions:
block_groups()
,
blocks()
,
counties()
,
county_subdivisions()
,
places()
,
pumas()
,
school_districts()
,
states()
,
tracts()
Examples
## Not run:
# Example: get ZCTAs that intersect the Memphis, TN urbanized area
library(tigris)
zcta1 <- zctas(cb = TRUE, starts_with = c("37", "38", "72"))
uas <- urban_areas()
memphis_ua <- uas[grep("Memphis", uas$NAME10), ]
mem_zcta <- zcta1[memphis_ua, ]
plot(mem_zcta$geometry)
## End(Not run)