6.6 Data sources

  • The USAboundaries package, https://github.com/ropensci/USAboundaries contains state, county and zip code data for the US.26 As well as current boundaries, it also has state and county boundaries going back to the 1600s.

  • The tigris package, https://github.com/walkerke/tigris, makes it easy to access the US Census TIGRIS shapefiles.27 It contains state, county, zipcode, and census tract boundaries, as well as many other useful datasets.

  • The rnaturalearth package28 bundles up the free, high-quality data from http://naturalearthdata.com/. It contains country borders, and borders for the top-level region within each country (e.g. states in the USA, regions in France, counties in the UK).

  • The osmar package, https://cran.r-project.org/package=osmar wraps up the OpenStreetMap API so you can access a wide range of vector data including individual streets and buildings29

  • If you have your own shape files (.shp) you can load them into R with sf::read_sf()

  1. Lincoln A. Mullen and Jordan Bratt, “USAboundaries: Historical and Contemporary Boundaries of the United States of America,” Journal of Open Source Software 3, no. 23 (2018): 314, https://doi.org/10.21105/joss.00314.↩︎

  2. Kyle Walker, Tigris: Load Census Tiger/Line Shapefiles, 2019, https://CRAN.R-project.org/package=tigris.↩︎

  3. Andy South, Rnaturalearth: World Map Data from Natural Earth, 2017, https://CRAN.R-project.org/package=rnaturalearth.↩︎

  4. Manuel J. A. Eugster and Thomas Schlesinger, “Osmar: OpenStreetMap and R,” R Journal, 2010, http://osmar.r-forge.r-project.org/RJpreprint.pdf.↩︎