Site icon R-bloggers

Maps of changes in area boundaries, with R

[This article was first published on Civil Statistician » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today a coworker needed some maps showing boundary changes. I used what I learned last week in the useR 2012 geospatial data course to make a few simple maps in R, overlaid on OpenStreetMap tiles. I’m posting my maps and my R code in case others find them useful.

A change in Census block-groups from 2000 to 2010, in Mobile, AL

U.S. Census Bureau geography can take a while to understand, and the boundaries used (for organizing data collection and for publishing tabulations) can change over time as the population shifts. The idea behind these maps was to illustrate some ways that Census block-groups can change from one decennial census to the next.

A change in Census block-groups from 2000 to 2010, in Autauga County, AL

The map boundaries are defined in shapefiles, which are publicly available for download at the 2010 TIGER/Line Shapefiles website. Select “Blocks” or “Block Groups,” then the state (Alabama), then the county (Autauga or Mobile) to download a zip file containing several geographic files.  Unzip them all into the same directory. You’ll also need to install the R packages sp, rgdal, and OpenStreetMap.

Then grab my R code, assign your own working directory to mydir, and you should be good to go:

For future work:

  1. After coding all this, I discovered a suite of UScensus R packages which apparently contain (or help to download?) spatial data for several levels of Census geography. These may provide an easier way to get the shapefiles, but I have yet to try them out.
  2. There must be a simpler way to get a bounding box big enough for all the block groups at once. I tried to combine the shapefiles together using rbind, but it didn’t work, perhaps because some of the variable names differ from Census 2000 to Census 2010 or from blocks to block-groups. So instead, I am getting the bounding box for each area separately, then find the max & min of the lats & longs across all areas.

Map data © OpenStreetMap contributors, CC BY-SA.

To leave a comment for the author, please follow the link and comment on their blog: Civil Statistician » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.