1

I would like to generate a map of the world in Mollweide projection, but centered on longitude 150. I would like to plot a raster and a vector map of the world on top.

library(maptools)
library(raster)
library(rgdal)

# generate some dummy data
data(wrld_simpl)
ras <- raster(ext=extent(wrld_simpl), res=c(2,2))
values(ras) <- runif(ncell(ras))
ras <- mask(ras, wrld_simpl, inverse=TRUE)

# Here is the map unprojected, without recentering
plot(ras)
plot(wrld_simpl, add=TRUE, col='black')

# now I transform to Mollweide 
mollproj <- '+proj=moll +lon_0=150 +ellps=WGS84'

# project raster
ext <- projectExtent(ras, mollproj)
rasMoll <- projectRaster(ras, to=ext)

# project vector map
wrldMoll <- spTransform(wrld_simpl, CRS(mollproj))

# plot
plot(rasMoll)
plot(wrldMoll, add=TRUE)

enter image description here

There are several problems here. The map is not at full extent, the vector map has horizontal lines, and there are floating pieces of the raster beyond the bounds of the world.

Any suggestions on how to get this to work?

Thanks!

Pascal
  • 1,590
  • 2
  • 16
  • 35
  • For the horizontal line, I worry that this is because of the shape file, or the map behind. I'm not sure you can do it with this projection and this center. I would recommand to download another world shapefile and to use ggplot2. – timat Oct 31 '16 at 17:47
  • On a quick glance, you haven't transformed your raster to the correct projection. Try adding `rasMoll <- projectRaster(rasMoll, crs = "+proj=moll +lon_0=150 +ellps=WGS84")` before plotting. – Roman Luštrik Oct 31 '16 at 17:47
  • I think directly projecting the raster vs projecting the extent are two alternative approaches, and both generate the same result in this case. – Pascal Oct 31 '16 at 18:09

0 Answers0