【问题标题】:Recenter map that crosses international dateline with ggplot and geom_sf使用 ggplot 和 geom_sf 跨越国际日期变更线的中心地图
【发布时间】:2022-08-03 04:29:58
【问题描述】:

考虑下面的欧洲地图。俄罗斯的部分地区在地图的另一边。我如何“重新居中”地图以减少空白空间?我想我需要以某种方式将左侧的多边形移动到右侧?

library(rnaturalearth)
library(tidyverse)

ne_countries(returnclass = \"sf\", continent = \"europe\") %>% 
  ggplot() + 
  geom_sf()

非常感谢!

reprex package (v2.0.1) 于 2022 年 7 月 2 日创建

标签: r ggplot2 geospatial sf rnaturalearth


【解决方案1】:

您可以使用 coord_sf() 函数为其提供一个新的坐标系,以将其转换为您感兴趣的区域在地图上的中心位置。

对于我的示例,我从https://projectionwizard.org/ 中获取了一个定义为众所周知的文本 (WKT) 的任意坐标系

library(rnaturalearth)
library(tidyverse)


domainCRS<- paste('PROJCS["ProjWiz_Custom_Lambert_Azimuthal"',
            'GEOGCS["GCS_WGS_1984"',
        'DATUM["D_WGS_1984"',
        'SPHEROID["WGS_1984",6378137.0,298.257223563]]',
        'PRIMEM["Greenwich",0.0]',
        'UNIT["Degree",0.0174532925199433]]',
        'PROJECTION["Lambert_Azimuthal_Equal_Area"]',
        'PARAMETER["False_Easting",0.0]',
        'PARAMETER["False_Northing",0.0]',
        'PARAMETER["Central_Meridian",109.69]',
        'PARAMETER["Latitude_Of_Origin",12.55]',
        'UNIT["Meter",1.0]]',
        sep = ',')

map<-ne_countries(returnclass = "sf", continent = "europe")
  ggplot() + 
  geom_sf(data = map)+
  coord_sf(crs = domainCRS)

【讨论】:

    猜你喜欢
    • 2021-08-16
    • 1970-01-01
    • 2012-12-01
    • 2021-12-24
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多