Nuts and Bolts: Modern maps of Eurasia in R

HolarticoMaps are quite useful things, if you want to convey information about where in the world something happens. But, turns out, they are harder to make than I naively thought! But not that hard.

There are tools available. Perhaps you have heard of/used ArcGIS? ArcGIS is a massive suite of extremely complicated and comprehensive software. But it’s not exactly user friendly, and did I mention it costs a bazillion dollars? But fear not! You can do it in R, as you can so many things. (If you need an intro to R, I am not the one to ask, but check out the R homepage and this sweet tutorial from Rich Fitzjohn.) Turns out there are many maptastic avenues available in R. It depends on what you need. Check out this really helpful and detailed blog post on mapping in R from Kim Gilbert and more on R, as well as some alternative free mapping programs from Dylan Burge.

If all you need to map is part of North America, wow are you set! You can do so many things, using just the maps that are natively included in the R packages that Kim and Dylan discuss (“maps”, “maptools”, “mapdata”, “scales”, “mapproj”, and “RgoogleMaps”). But what if you need to map a large area? Shouldn’t the area of a continent on your map be somehow  related to reality? Then you need a projection.There are even some projection options available in these packages, and if you are mapping a small enough area, maybe you don’t even need to worry about projections. Projections can be tricky.

And if you happen to want to make a projected map of Eurasia that doesn’t include relics like Czechslovakia and the USSR, then things get a bit trickier. Because who would want to do that, silly invasion biologist, studying GLOBAL PROBLEMS? So with encouragement from Dylan Burge and invaluable help from Andy South, the creator of the rworldmap package, here’s what I came up with. Read more about this package here: rworldmap write-up, and some worked examples, and you’re not too late to register for a rworldmap tutorial at the useR2013 conference in Spain in July.

Because the species I am working on, Centaurea diffusa, could now be considered holarctic, including it’s invaded range, I need a map of the entire northern hemisphere. So I settled on a Lambert azimuthal equal area projection, with the North Pole in the center, like you were looking straight down on the globe. I also wanted to color-code countries to indicate the species range, and plot collection points. I’ve included my complete code and comments as a gist on GitHub (because WordPress.com won’t let me have plugins).

Here’s the (maybe) final product!

Range and collection map of Centaurea diffusa

Range and collection map of Centaurea diffusa

Andy South. rworldmap: A New R package for Mapping Global Data. The R Journal, 3(1):35-43, June 2011. [ bib | .pdf ]

3 thoughts on “Nuts and Bolts: Modern maps of Eurasia in R

  1. Pretty cool. Am more and more in awe of R and the packages folks have developed. An online alternative that I hope does much of the what folks desire is my pet project, SimpleMappr at http://www.simplemappr.net. It has an API so one day I’ll see if I can make an R package of my own that ought to be fairly lightweight. I do all the heavy lifting on my end. One issue I continue to grapple with is to wrap maps (and polygons) across the International Dateline with world geographic projections. Does what you have in R accommodate that?

    • Hey, your pet project looks pretty cool! I really don’t know much about what happens ‘under the hood’ of rworldmap or the other R mapping packages. For rworldmap, I recommend you ask the horse’s mouth, Andy South. You can catch him at @southmapr.

  2. Pingback: Nuts and Bolts: Modern maps of Eurasia in R | R...

Leave a reply to David Shorthouse (@dpsSpiders) Cancel reply