I want to project this map in robinson projection:

world <- map_data("world")
ggplot() + geom_path(data = world, 
                              aes(long, lat, group = group))

enter image description here

And I would like to change the projection to "Robinson" (following advice from answer to my previous question: What projection does the global climate region map from Wikipedia use?

I had a hard time finding a default implementation of this projection, I worked out the following for using the proj4 library:

robinson <- project(cbind(world$long, world$lat), 
                    proj = "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

I have tried a number of approaches, including:

# using ggmap::get.map()
get_map("world", projection = mapprojection(robinson))
# using ggplot2::coord_map
coord_map(projection = robinson)
# and sp::coordinates:
coordinates(world) <- ~ lat + long
gridded(world) <- TRUE # returns error
proj4string(world) <- CRS(robinson)

but none of these work. Is it a typo, or I missing something fundamental about this method?


2 Answers 2


It might be tricky to handle Robinson from within ggplot2.

AFAIK ggplot2 coord_map solution you explored will use projection information as defined in mapproject package. There are few available there but unfortunately Robinson is not one of them and I'm not sure if you can add your own.

Also - the world data you are using (from ggmap package I presume) is already a data frame class. So you will not be able to reproject it easily (?).

My suggestion would be start from scratch using shape file and handle geographical data before passing them to ggplot2. My cursory solution using Natural Earth data would follow this steps:


# get data
download.file(url="http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_countries.zip", "ne_110m_admin_0_countries.zip", "auto")

# read shape file using rgdal library
ogrInfo(".", "ne_110m_admin_0_countries")
world <- readOGR(".", "ne_110m_admin_0_countries")
plot(world, col = "grey")  

readOGR uses information about the projection from prj file and summary now tells me now that world is now

Object of class SpatialPolygonsDataFrame
   min       max
x -180 180.00000
y  -90  83.64513
Is projected: FALSE 
proj4string :
[+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0]

And looks like that:

enter image description here

Let's transform to Robinson:

worldRobinson <- spTransform(world, CRS("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
plot(worldRobinson, col = "grey")  

Summary is now:

Object of class SpatialPolygonsDataFrame
        min      max
x -16810131 16810131
y  -8625154  8343004
Is projected: TRUE 
proj4string :
[+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0]

And it looks like that:

enter image description here

From here you should be able to continue with ggplot (fortify might be needed).


You can now do this directly with the ggalt package:


wrld <- map_data("world")

gg <- ggplot()
gg <- gg + geom_map(data=wrld, map=wrld,
                    aes(x=long, y=lat, map_id=region),
                    color="#2b2b2b", size=0.15, fill=NA)
gg <- gg + coord_proj("+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")
gg <- gg + theme_map()

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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