I've been experimenting with choropleth mapping techniques in R, having reaped the benefits of ggplot2 for creating beautiful graphs within a powerful data analysis package.

When it comes to mapping I've failed to produce results comparable to those I routinely get from QGIS. Using data of flow in Sheffield (fully replicable data and .qgs file here), QGIS easily produced the following:

QGIS image

The best I could produce using R (using code described here) were these two maps, the first using GISTools, the second using ggplot2:

GISTools choropleth ggplot2 choro

To me, the ggplot2 option seems far more attractive, if only I could solve the problem of the faulty lines (probably a problem with the fortify() command, or not reading in shapefiles using readOGR() described here.)

So the question is 2-fold: is the ggplot2 option the best choropleth mapping solution in R and, if so, how can I solve the problem of the faulty white lines?

Replicable code to find out what I've done is here.

Edit - Since made choropleth() output option more attractive:

New Rplot

The ugliness of this option can be reduced by exporting at higher resolution and removing the legend (other R legends are available). Still not managed to change line thickness but it's getting better! Red lines represent flows to zones which employ > 5000 people.

  • 1
    The first R map would look alot nicer if you reduced the size of the polygon outlines (and perhaps made them completely transparent as in the first QGIS example).
    – Andy W
    Dec 8, 2012 at 15:27
  • 3
    Agreed, but I don't know how to do this - the code I used was "choropleth(oas, v = oas$to, shades)". Searched for documentation to remove lines, but found nothing: cran.r-project.org/web/packages/GISTools/GISTools.pdf Dec 8, 2012 at 15:37
  • 1
    @RobinLovelace If you put your R code up we can surely help you with these issues, but without a reproducible example it's not easy to pinpoint the issues. I do appreciate the effort you have made to put up the (useful) screenshots, but the images are just the icing that should be delivered on top of the cake of the source code. Dec 21, 2012 at 7:10
  • Please see reproducible code contained in this .zip folder, as stated above: dl.dropbox.com/u/15008199/Rflows-simple.zip Dec 21, 2012 at 7:59
  • @RobinLovelace Thanks, interesting, have downloaded Dec 21, 2012 at 11:09

1 Answer 1


There are some great resources on exactly this very interesting subject, including:

From Revolutions:

Choropleth Map R Challenge

Choropleth Challenge Results

From Stack Overflow.se:

Developing Geographic Thematic Maps with R

There are excellent examples of choropleth maps and their associated R code, including my favorite (i.e. attached map) using ggplot2. It should be relatively straight forward to insert your own data set into one of the script examples.

R Code for this map available from This is the Green Room

  • Many thanks for flagging these excellent resources and for showing the unemployment map of the USA. Missing a legend though! Any suggestions how to translate these resources into maps of Sheffield? Code snippets to sort out my failed attempt at choropleth mapping using ggplot2 and the data I've supplied of Sheffield very much appreciated! Dec 9, 2012 at 17:07
  • @RobinLoveLace I'm glad the links were useful to you. You should have no problem plugging in your own dataset into the many sample scripts, although you may have to roll up your sleeves and do a bit of trial and error on the specific packages. Unfortunately, I do not have the time now to do it for you--sorry!
    – Aaron
    Dec 9, 2012 at 17:22
  • 1
    I'll have a play and hopefully add further edits and replicable code when the map improves. Dec 9, 2012 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.