Skip to content
Prev 23384 / 29559 Next

making wrld_simpl longitude borders something other than (-180, 180)

Although, unfortunately, the exact code, but switching "moll" to "latlong",
produces screwups (horizontal lines throughout the plot). Any advice?

Works:
====================
pdffn = "wrld_simpl_moll.pdf"
pdf(file=pdffn, width=12, height=6)

data(wrld_simpl) #The world as a SpatialPolygonsDataFrame
#To avoid the lines crossing the map after reprojection we need to cut the
polygons at the new break:
w <- nowrapRecenter(wrld_simpl, offset = 180-90, avoidGEOS=TRUE)
#Then proceed with the reprojection (note the proj4 string for a mollweide
projection with 150?E as the new center)
wrld_reCentered <- spTransform(w, CRS("+proj=moll +lon_0=-90"))
plot(wrld_reCentered, border="grey", lwd=0.5)


dev.off()
cmdstr = paste0("open ", pdffn)
system(cmdstr)
====================


Produces screwups:
====================
pdffn = "wrld_simpl_latlong.pdf"
pdf(file=pdffn, width=12, height=6)

data(wrld_simpl) #The world as a SpatialPolygonsDataFrame
#To avoid the lines crossing the map after reprojection we need to cut the
polygons at the new break:
w <- nowrapRecenter(wrld_simpl, offset = 180-90, avoidGEOS=TRUE)
#Then proceed with the reprojection (note the proj4 string for a mollweide
projection with 150?E as the new center)
wrld_reCentered <- spTransform(w, CRS("+proj=longlat +lon_0=-90"))
plot(wrld_reCentered, border="grey", lwd=0.5)


dev.off()
cmdstr = paste0("open ", pdffn)
system(cmdstr)
====================
On Mon, Sep 14, 2015 at 4:04 PM, Nick Matzke <matzke at nimbios.org> wrote: