Spatial (GIS) data in R: easy maps

Most, if not all, paper topics will benefit from finding books and articles discussing (and giving code for) relevant techniques. Common examples in the past have been text mining and web scraping. Another example is analyzing spatial data. There are R functions for a full range of geographic modeling, including both analysis and display. Several groups are planning to look at Airbnb or other data where space is important.

  • This page recommends ggmaps package. I have zero experience with ggmaps, but it produced the above bike-route map in 3 lines of ggplot2 code, including one line to import the map itself from Google.  The author claims:

    You might be able to get better looking maps at some resolutions by using shapefiles and rasters from but ggmap will get you 95% of the way there with only 5% of the work!

  • For more depth, here are some books, downloadable from UCSD. Generally you will only need a few chapters
    • Displaying Time Series, Spatial, and Space-Time Data with R by Oscar Perpiñán Lamigueir
    • Applied Spatial Data Analysis with R, 2nd edition, Roger S. Bivand, Edzer Pebesma, Virgilio Gómez-Rubio

For sources on text mining, web scraping, and other special topics, see information on this page and elsewhere on this blog. Supplemental Readings – still valid in 2017

From the datasciencecentral page:
ggplot(states, aes(x = long, y = lat, group = group, fill = le_black)) +
geom_polygon(color = “white”) +
scale_fill_gradient(name = “Years”, low = “#ffe8ee”, high = “#c81f49”, guide = “colorbar”, na.value=”#eeeeee”, breaks = pretty_breaks(n = 5)) +
labs(title=”Life expectancy in African American”) +

Updated June 7, 2017

Author: Roger Bohn

Professor of Technology Management, UC San Diego. Visiting Stanford Medical School Twitter =Roger.Bohn

One thought on “Spatial (GIS) data in R: easy maps”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s