GIS in R: Part 1

I messed around with R for years without really learning how to use it properly. I think it’s because I could always throw my hands up when the going got tough and run back and cling the skirts of Excel or JMP or Systat. I finally learned how to use R when I needed to do a fairly hefty GIS project and I didn’t have access to a computer with ArcGIS and couldn’t afford to buy it (who can?). So I started looking into R’s spatial abilities.

Admittedly R might not be the most obvious choice for free GIS options, combinations of QGIS (, GRASS (, PostGIS (, or OpenGeo ( might pop up in google searches before R. R might not even be the first general purpose programming language you think of for GIS, especially now that ArcGIS relies on Python for much of its modeling. However, all of these tools have a significant learning curve, and I was farther along in R than any of these alternatives, so I started googling and watching tutorial videos. So should you be using R for analyzing and displaying spatial data? If you already know a little or a lot of R, if you need a cross platform solution, or need to do some fairly heavy stats applications to your spatial data, R just might be a good solution for you. It turns out R has lots of support for spatial data and does a great job displaying it too.

There are a number of packages useful for analyzing and displaying your spatial data. I think the 4 most useful right out of the gate are sp, rgdal, maptools, and raster. If you haven’t installed packages before do this…


…and if you are on a Windows machine…


If you’re on a Mac, installing rgdal is a little tricky. Give this a try


If that doesn’t work read this over.

After installing the packages, if you want to use the functions contained in that package you need to load the library. To use the functions in the sp package, you should type


to load the rgdal package…




, , ,

One Response to GIS in R: Part 1

  1. Justin PargeterNo Gravatar 5 March, 2015 at 12:28 pm #

    I’m very interested in using R for spatial analysis and display, are there any specific sources you’d recommend to get started? I already have a working knowledge of R for stats purposes.


Leave a Reply


Powered by WordPress. Designed by Woo Themes