Importing ESRI shape files into R

Several organizations make ESRI shape files freely available, and you can adapt them for your purposes. Using RgoogleMaps is easy, and we have seen that it offers very little control over map elements and plotting. Importing shape files, on the other hand, gives us total control. We should prefer this approach when we need fine control over the rendering of individual elements rather than just plotting a map image as a whole. The rgdal package offers the functionality to download shape files into R in a format that the sp package can handle.

Getting ready

Install the rgdal and sp packages. At the time of writing, installing rgdal on Mac OS X is tricky. Binary packages are unavailable and different versions of the ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.