Wednesday, 11 February 2015

r - Lines on reprojected sp objects with Mollweide projection


I'm having an odd problem such that when I reproject maps to a Mollweide projection in R using sp, I get additional lines stretching across the globe. What is going on here, and do you have any suggestions to fix it. Here's a reproductible example:


library(sp)
library(maps)
library(maptools)

worldmap <- map("world", plot=F)

plot(worldmap, type="l)

So far, so good. I get worldmap


So now I reproject. This is a CRS I'm using to be compatible with some other projects. Note how world-spanning lines then crop up.


worldmapLines <- map2SpatialLines(worldmap,
proj4string=CRS("+proj=longlat +datum=WGS84"))

worldM <- spTransform(worldmapLines,
CRS("+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs"))


plot(worldM)

enter image description here




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...