Plotting Maps with R

[This article was first published on Playing with 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.

I stumbled upon this tutorial while not studying and I thought it would be fun to try and plot maps of the San Francisco Bay Area household income, education, population density, poverty, etc…

To do this I needed a Shapefile for the Bay Area zip codes similar to the London borough file used in the tutorial. I found a .shp file for the Bay Area zip code boundaries here.

I have a demographic database on my computer that I used to add the needed information to the Shapefile. In the code I included a vector of the median household incomes for the corresponding zipcodes in the the .shp file.

The following code is only slightly modified from the code included in the Spatial Analysis tutorial.


## set the working directory.

## load the shapefile

This is the map that results from the code above.

Here is a visualization of the population density in the Bay Area.

Finally, here is a visualization of the percent of adults (25 years or older) with a bachelors degree or higher.

I’m not familiar with GIS software so I imagine that this is sort of a round about way of doing something pretty simple, but I think the results are cool.

To leave a comment for the author, please follow the link and comment on their blog: Playing with R. 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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)