[R-sig-Geo] world map problem with Mollweide projection

Roger Bivand Roger.Bivand at nhh.no
Mon Nov 6 12:47:47 CET 2017


On Mon, 6 Nov 2017, Elias T Krainski wrote:

> Dear all,
>
> Anybody knows a easy way how to get rid of those east-west lines at the north 
> in the following plot:
>
> library(maps)
> map('world',, projection='mollweide')

In sp (can be done in sf too, I think):

wrld <- map("world", fill=TRUE, plot=FALSE)
library(sp)
library(maptools)
ID <- sapply(strsplit(wrld$names, ":"), "[", 1L)
wrld_sp <- map2SpatialPolygons(wrld, ID=ID)
proj4string(wrld_sp) <- "+proj=longlat +datum=WGS84"
wrld_sp1 <- nowrapSpatialPolygons(wrld_sp, offset=180)
library(rgdal)
wrld_moll <- spTransform(wrld_sp1, CRS("+proj=moll"))
plot(wrld_moll)

The lines or polygons crossing 180 degrees need to be broken into two 
parts at 180 +/- eps; that isn't easy in the maps package.

Roger

>
> best regards,
>
> Elias
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
Editor-in-Chief of The R Journal, https://journal.r-project.org/index.html
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



More information about the R-sig-Geo mailing list