world map problem with Mollweide projection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

world map problem with Mollweide projection

Elias T Krainski
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')

best regards,

Elias

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: world map problem with Mollweide projection

Roger Bivand
Administrator
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
> [hidden email]
> 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: [hidden email]
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

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Reply | Threaded
Open this post in threaded view
|

Re: world map problem with Mollweide projection

Elias T Krainski
It works. Thank you!

best wishes,

Elias

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: world map problem with Mollweide projection

Roger Bivand
Administrator
And the sf version (using the development master from github):

library(maps)
library(sf)
wrld <- st_as_sf(maps::map("world", fill=TRUE, plot=FALSE))
wrld_wrap <- st_wrap_dateline(wrld, options =
   c("WRAPDATELINE=YES", "DATELINEOFFSET=180"), quiet = TRUE)
wrld_moll <- st_transform(wrld_wrap, "+proj=moll")
plot(st_geometry(wrld_moll), col="transparent")

See: https://github.com/r-spatial/sf/issues/541

Roger


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

> It works. Thank you!
>
> best wishes,
>
> Elias
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> 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: [hidden email]
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

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand
Department of Economics
Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway