How to switch to a map that is centered on the Chi

2019-08-26 06:30发布

问题:

I have been using R to plot a world map and I want to switch to a map that is centered on the Pacific ocean and splits the Atlantic to make my data plot easier.

But the default set of R is like this:

 map("world") 

And I want the map to be like this:

I have tried the help of R worldmap the option "orientation" Even though the help says that " orientation a vector c(latitude, longitude, rotation) describing where the map should be centered and a clockwise rotation (in degrees) about this center. " I still could not use it for example like the following command only produce this:

 map("world",orientation=c(35,104,0)) 

 Warning:
 In map("world", orientation = c(35, 104, 0)) :
 projection failed for some data

the result is like this:

The result is strange. So how can I get something right like Picture 2 have shown? Thank you.

回答1:

Your example picture seems to be centered around 0 lat, 150 lon. The following seems to roughly generate you example picture:

library(maps)
map("world",orientation=c(90, 150,0), projection="mollweide", wrap=TRUE) 

For some reason it appears you need to add 90 to your longitude.



回答2:

This is a more complex solution but a nice training exercise to learn how to deal with SpatialPolygons objects.

library(maptools)
library(rgdal)
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-150, avoidGEOS=TRUE)
#Then proceed with the reprojection (note the proj4 string for a mollweide projection with 150°E as the new center)
wrld_china <- spTransform(w, CRS("+proj=moll +lon_0=150"))
plot(wrld_china)



标签: r map