Pages Menu
Categories Menu

Posted by on Jan 10, 2012 in R Spatial, Resources, Spatial Analysis, Visualisation | 5 comments

Coming of Age: R and Spatial Data Visualisation

I have been using R (a free statistics and graphics software package) now for the past four years or so and I have seen it become an increasingly powerful method of both analysing and visualising spatial data. Crucially, more and more people are writing accessible tutorials (see here) for beginners and intermediate users and the development of packages such as ggplot2 have made it simpler than ever to produce fantastic graphics. You don’t get the interactivity you would with conventional GIS software such as ArcGIS when you produce the visualisation but you are much more flexible in terms of the combinations of plot types and the ease with which they can be combined. It is, for example, time consuming to produce multivariate symbols (such as those varying in size and colour) in ArcGIS but with R it is as simple* as one line of code. I have, for example, been able to add subtle transitions in the lines of the migration map above.  Unless you have massive files, plotting happens quickly and can be easily saved to vector formats for tweaking in a graphics package.

R’s utilisation has been tempered by its relatively sparse documentation and challenging usability. The R community is increasingly aware of this with packages such as DeducerSpatial providing a graphical user interface to some of R’s spatial data functionality. More and more tutorials are appearing and people have been inspired by some high profile maps made with R (see here) so I am confident that it will be increasingly seen as the engine for slightly glossier analysis and visualisation packages.

R can’t do everything- I find handling map projections a bit tricky and its not possible to pan and zoom the maps as they are being created. In some circumstances I can’t do without these functions so I opt for a traditional GIS. Also, for the programmers out there used to the likes of Python and Java, R can have quite a few quirks in its syntax so be patient. Despite it’s flaws, if you have a large data processing and visualisation task R is a great option. It offers a high degree of flexibility in terms of input data formats and with packages such as twitteR, RCurl, and XML it is easier than ever to import online data sources from social media sites and data feeds.  Aside from traditional export formats for the visualisations it has become incredibly simple to export interactive and animated graphics using the googleVIS package or igraph for network visualisations. Such flexibility is invaluable if you are seeking to create a variety of different graphics from a single datasource without having to format it for multiple software packages. The great thing with R is the sense that it still has masses of unrealised potential for  future spatial data visualizations. If you know of any good visualisations or tutorials please leave a comment!

I should also say that if you would like to learn how to do these sorts of visualisations (and more!) come and do our masters course!

*simple might be a slightly optimistic way of thinking about it if you haven’t used R before, but with a bit of practice you will ge there! 


  1. Thanks, this is very interesting to read. Do you think R would be able to produce camera-ready graphs and charts for academic papers, i.e. ones that could be output in a vector format suitable for incorporation, via LaTeX/pdfTeX, into a PDF, or into a Word document? Previously I have used IDL for this.

    • @Ollie, yes, R is is ideally set up for this. You can draw your plots on PDF or Postscript devices to produce vector-based plots for publication, or to an SVG device for editing in a vector drawing package. I have been doing this for some time now. PDF is fine for LaTeX/pdfTeX but EPS via the postscript() device is probably best for MS Word – and send the original EPS files as Word can make a mess of inserting EPS files directly. For MS Word, don’t worry about the on screen quality – it only shows a low-res bitmap of the EPS generated during import into Word.

  2. Hey guys — great post. I wanted to add two things. 1) you’ve probably noticed maps can blow up file sizes. It is for this reason that bitmap (png,jpeg) support was added to figure code chunks in Sweave.

    2) For projections, it’s true. You need rgdal to make spTransform work. I have some notes on this in osx at least but perhaps it is helpful to other unix variants.


  1. Coming of Age: R and Spatial Data Visualisation « Another Word For It - [...] Coming of Age: R and Spatial Data Visualisation by James Cheshire. [...]
  2. Great Maps with ggplot2 | Spatial Analysis - [...] above map (and this one) was produced using R and ggplot2 and serve to demonstrate just how sophisticated R…
  3. Starting Analysis and Visualisation of Spatial Data with R | Spatial Analysis - [...] and it is becoming increasingly recognised as a tool for data visualisation (I wrote about this last year, also see here)…

Post a Reply

Your email address will not be published. Required fields are marked *