Download TIGER/Line shapefiles from the United States Census Bureau (< https://www.census.gov/geo/maps-data/data/tiger-line.html>) and load into R as 'sf' objects.
Download and use Census TIGER/Line shapefiles in R
tigris
is an R package that allows users to directly download and use TIGER/Line shapefiles (https://www.census.gov/geo/maps-data/data/tiger-line.html) from the US Census Bureau.
To install the package from CRAN, issue the following command in R:
install.packages('tigris')
Or, get the development version from GitHub:
devtools::install_github('walkerke/tigris')
In version 0.6:
tigris_cache_dir()
function:library(tigris)tigris_cache_dir("PATH TO YOUR CUSTOM CACHE DIRECTORY")# Restart Roptions(tigris_use_cache = TRUE)
tigris now defaults to the 2016 TIGER/Line and cartographic boundary shapefiles.
Thanks to contributors from Transport Foundry (https://github.com/transportfoundry), tigris now includes some geolocator functions. For example, to find out the Census block ID of a given address:
call_geolocator("2850 S University Dr", "Fort Worth", "TX") Address (2850 S University Dr Fort Worth TX) returned more than one address match. The first match was returned.[1] "484391042014000"
To learn how to use the package, I'd recommend the following materials:
Available datasets:
Please note: cartographic boundary files in tigris are not available for 2011 and 2012.
Function | Datasets available | Years available |
---|---|---|
nation | cartographic (1:5m; 1:20m) | 2013, 2014, 2015 |
divisions | cartographic (1:500k; 1:5m; 1:20m) | 2013, 2014, 2015 |
regions | cartographic (1:500k; 1:5m; 1:20m) | 2013, 2014, 2015 |
states | TIGER/Line; cartographic (1:500k; 1:5m; 1:20m) | 1990, 2000, 2010, 2011, 2012, 2013, 2014, 2015 |
counties | TIGER/Line; cartographic (1:500k; 1:5m; 1:20m) | 1990, 2000, 2010, 2011, 2012, 2013, 2014, 2015 |
tracts | TIGER/Line; cartographic (1:500k) | 1990, 2000, 2010, 2011, 2012, 2013, 2014, 2015 |
block_groups | TIGER/Line; cartographic (1:500k) | 1990, 2000, 2010, 2011, 2012, 2013, 2014, 2015 |
blocks | TIGER/Line | 2000, 2010, 2011, 2012, 2013, 2014, 2015 |
places | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
pumas | TIGER/Line; cartographic (1:500k) | 2012, 2013, 2014, 2015 |
school_districts | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
zctas | TIGER/Line; cartographic (1:500k) | 2000, 2010, 2012, 2013, 2014, 2015 |
congressional_districts (114th Congress) | TIGER/Line; cartographic (1:500k; 1:5m; 1:20m) | 2014, 2015 |
state_legislative_districts | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
voting_districts | TIGER/Line | 2012 |
area_water | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
linear_water | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
coastline | TIGER/Line | 2013, 2014, 2015 |
core_based_statistical_areas | TIGER/Line; cartographic (1:500k; 1:5m; 1:20m) | 2011, 2012, 2013, 2014, 2015 |
combined_statistical_areas | TIGER/Line; cartographic (1:500k; 1:5m; 1:20m) | 2011, 2012, 2013, 2014, 2015 |
metro_divisions | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
new_england | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
county_subdivisions | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
urban_areas | TIGER/Line; cartographic (1:500k) | 2012, 2013, 2014, 2015 |
primary_roads | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
primary_secondary_roads | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
roads | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
rails | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
native_areas | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
alaska_native_regional_corporations | TIGER/Line; cartographic (1:500k) | 2011, 2012, 2013, 2014, 2015 |
tribal_block_groups | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
tribal_census_tracts | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
tribal_subdivisions_national | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
landmarks | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
military | TIGER/Line | 2011, 2012, 2013, 2014, 2015 |
You are now able to specify a custom cache directory for your data. To set the cache directory, use the new tigris_cache_dir()
function.
tigris now defaults to the 2016 TIGER/Line and cartographic boundary shapefiles.
Thanks to contributors from Transport Foundry (https://github.com/transportfoundry), tigris now includes some geolocator functions.
tigris now downloads data to a temporary directory rather than creating a cache directory by default to conform with CRAN policies. To enable caching of data, set options(tigris_use_cache = TRUE)
in your R script or .Rprofile.
2000 and 2010 Zip Code Tabulation Areas (ZCTAs) are now available.
tigris now will return objects of class 'sf' if requested by the user with the argument class = 'sf'
or by setting the option options(tigris_class = 'sf')
.
Historical states, counties, Census tracts, and block groups are now available going back to 1990
In the event of a download error, tigris will attempt to re-download without the user having to request it.
Various improvements and bug fixes.
tigris now accommodates county name changes in the 2015 TIGER/Line dataset. Shannon County, SD (FIPS code 113) is now Oglala Lakota County (FIPS code 102), and Wade Hampton Census Area, AK (FIPS code 270) is now Kusilvak Census Area (FIPS code 158).
fixed a bug that would counties not to load in non-interactive mode
New function, voting_districts()
, enables users to retrieve voting district (electoral precinct) shapefiles from the 2012 TIGER/Line dataset.
tigris now imports and re-exports the plot()
function from the sp package so that Census shapefiles can be plotted without having to load sp explicitly.
Enhancements to the geo_join function to merge tabular data frames to spatial data frames. An optional parameter, by, allows you to supply one column name to merge on if the column names are the same.
geo_join also accommodates inner joins as well. By supplying 'inner' to the new how parameter, the resultant spatial data frame will retain only those rows that match the target tabular data frame.
Various improvements and bug fixes.