以太平洋为中心的Robinson投影与GGR图

以太平洋为中心的Robinson投影与GGR图,r,dictionary,ggplot2,map-projections,R,Dictionary,Ggplot2,Map Projections,我正试图用ggplot在R中创建一个以太平洋为中心的罗宾逊投影 使用spTransform将shapefile转换为Robinson CRS并将经度设置为150度是行不通的,并且会强化错误 像这样: world_robin <- spTransform(world2, CRS("+proj=robin +lon_0=150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")) plot(world_robin, col =

我正试图用ggplot在R中创建一个以太平洋为中心的罗宾逊投影

使用spTransform将shapefile转换为Robinson CRS并将经度设置为150度是行不通的,并且会强化错误

像这样:

world_robin <- spTransform(world2, CRS("+proj=robin +lon_0=150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
plot(world_robin, col = "khaki", bg = "azure2")
这似乎是最好的,但并不完全如此

这需要GDAL/rgdal,它是180对150,但你应该能够推断。太好了

library(ggplot2)
library(ggthemes)
library(sp)
library(rgdal)

# assumes you are in the ne_110m... directory
# split the world and stitch it back together again

system("ogr2ogr world_part1.shp ne_110m_admin_0_countries.shp -clipsrc -180 -90 0 90")
system("ogr2ogr world_part2.shp ne_110m_admin_0_countries.shp -clipsrc 0 -90 180 90")
system('ogr2ogr world_part1_shifted.shp world_part1.shp -dialect sqlite -sql "SELECT ShiftCoords(geometry,360,0), admin FROM world_part1"')
system("ogr2ogr world_0_360_raw.shp world_part2.shp")
system("ogr2ogr -update -append world_0_360_raw.shp world_part1_shifted.shp -nln world_0_360_raw")

world <- readOGR("ne_110m_admin_0_countries/world_0_360_raw.shp", "world_0_360_raw")
world_robin <- spTransform(world, CRS("+proj=robin +lon_0=180 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))

world_dat <- fortify(world_robin)

gg <- ggplot()
gg <- gg + geom_map(data=world_dat, map=world_dat,
                    aes(x=long, y=lat, map_id=id),
                    fill="khaki", color="black", size=0.25)
gg <- gg + coord_equal()
gg <- gg + theme_map()
gg <- gg + theme(plot.background=element_rect(fill="azure2"))
gg
您也可以使用gdalUtils进行此操作,但它只调用系统二进制文件,您必须使用已知字符串指定剪裁多边形,以便系统调用比行短几个字符

仅供参考:这样做意味着您必须在使用ggplot2打印之前移动并投影所有点/形状。

您需要GDAL/rgdal进行此操作,它是180对150,但您应该能够进行外推。太好了

library(ggplot2)
library(ggthemes)
library(sp)
library(rgdal)

# assumes you are in the ne_110m... directory
# split the world and stitch it back together again

system("ogr2ogr world_part1.shp ne_110m_admin_0_countries.shp -clipsrc -180 -90 0 90")
system("ogr2ogr world_part2.shp ne_110m_admin_0_countries.shp -clipsrc 0 -90 180 90")
system('ogr2ogr world_part1_shifted.shp world_part1.shp -dialect sqlite -sql "SELECT ShiftCoords(geometry,360,0), admin FROM world_part1"')
system("ogr2ogr world_0_360_raw.shp world_part2.shp")
system("ogr2ogr -update -append world_0_360_raw.shp world_part1_shifted.shp -nln world_0_360_raw")

world <- readOGR("ne_110m_admin_0_countries/world_0_360_raw.shp", "world_0_360_raw")
world_robin <- spTransform(world, CRS("+proj=robin +lon_0=180 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))

world_dat <- fortify(world_robin)

gg <- ggplot()
gg <- gg + geom_map(data=world_dat, map=world_dat,
                    aes(x=long, y=lat, map_id=id),
                    fill="khaki", color="black", size=0.25)
gg <- gg + coord_equal()
gg <- gg + theme_map()
gg <- gg + theme(plot.background=element_rect(fill="azure2"))
gg
您也可以使用gdalUtils进行此操作,但它只调用系统二进制文件,您必须使用已知字符串指定剪裁多边形,以便系统调用比行短几个字符


仅供参考:这样做意味着您必须在使用ggplot2绘图之前移动并投影所有点/形状。

p.s.我使用的是一个距离自然地球1:110m的形状文件。您可以编辑问题,而不是将其添加到注释中。p.s。我使用的是来自自然地球的1:110米形状文件。你可以编辑问题,而不是将其添加到评论中。太好了。非常感谢,太好了。非常感谢。