Download and use Census TIGER shapefiles in R
Current version: 0.1 (updated 11 October 2015)
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')
Basic usage:
library(tigris)
library(sp)
# Basic plot of US urbanized areas
ua <- urban_areas(cb = TRUE)
plot(ua)
# Interactive Leaflet map (requires the leaflet R package)
library(leaflet)
ua %>% leaflet() %>% addTiles() %>% addPolygons(popup = ~NAME10)
For more information on how to use this package, please view the RPubs at http://rpubs.com/walkerke/tigris01.
In Version 0.1:
- The
detailedparameter is now deprecated; replace it withcb = TRUEto get cartographic boundary files. When applicable, this allows users to get very-generalized cartographic boundary files by supplying5mor20mto theresolutionparameter. - There is much more documentation available! Keep an eye out, we hope to have the package on CRAN soon.
In Version 0.0.8:
tigrisnow caches shapefile downloads! Download the file once, andtigriswill store the downloaded shapefile in a special directory so you don't have to re-download every time. To turn off this behavior, change the option withoptions(tigris_use_cache = FALSE).tigrisis also now much smarter when handling geography arguments. For example,tracts("TX", "Dallas")will get you Census tracts for Dallas County, TX without having to know the FIPS code.- You can combine multiple
tigrisobjects of the same type with the newrbind_tigrisfunction - Multiple years are now supported!
tigrisdefaults to 2014, but you can change years with the newtigris_yearoption. For example, specifyingoptions(tigris_year = 2015)will telltigristo download the new 2015 TIGER/Line files in your R session. A caution: not everything is available in every year; for example, generalized cartographic boundary files are not released for 2015 yet, so thedetailed = FALSEargument won't work. - There is much more - download the package and try it out!
Version 0.0.5 release highlights:
- Many new geographies are available for download - state legislative districts, urbanized areas, Native American areas, and lots more!
- For many geographies (e.g. states, counties, Census tracts, etc.) an optional argument,
detailed = FALSE, can be supplied to download simplified (smaller) shapefiles. While not recommended for analysis, their smaller size makes them better for mapping. - A new function,
lookup_code, allows you to look up FIPS codes for states and counties interactively. - Zip Code Tabulation Areas (ZCTAs) have an optional parameter,
starts_with, that allows you to supply an argument to return only those ZCTAs that begin with that string