最近的地图与GGPLOT和GEOM_SF越过国际数据线

发布于 2025-02-12 09:13:26 字数 471 浏览 1 评论 0 原文

考虑下面的欧洲地图。俄罗斯的部分地区位于地图的另一侧。我将如何“最近”地图“最近”,以使空的空间更少?我想我需要以某种方式将左侧的多边形移到右侧吗?

library(rnaturalearth)
library(tidyverse)

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

非常感谢!

Consider the map of Europe below. Parts of Russia are on the other side of the map. How might I "recenter" the map so that there is less empty space? I guess I need to somehow move the polygons on the left to the right?

library(rnaturalearth)
library(tidyverse)

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

enter image description here

Thank you very much!

Created on 2022-07-02 by the reprex package (v2.0.1)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

就像说晚安 2025-02-19 09:13:26

您可以使用COORD_SF()函数给它一个新的坐标系,以将其转换为您感兴趣的区域中心的位置。

在我的示例中,我从: httpps://proctionwizard.org/

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)

you can give it a new coordinate system to transform it to where your area of interest is centered on your map using the coord_sf() function.

for my example I grabbed a somewhat arbitrary coordinate system defined as well known text (WKT) from: https://projectionwizard.org/

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文