R:在X和Y轴上使用真实的LON/LAT值

发布于 2025-01-29 13:13:06 字数 1033 浏览 3 评论 0原文

生成以下图表

library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(rworldmap)
library(scales)
library(sf)
library(mapdata)
library(maptools)
library(ggthemes)

data(wrld_simpl)

antarctica <- wrld_simpl[wrld_simpl$NAME == "Antarctica", ]
pr <- "+proj=laea +lat_0=-90 +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
antarctica.laea <- spTransform(antarctica, CRS(pr))

antarctica_plot <- ggplot() +
  geom_polygon(data = antarctica.laea, aes(x=long, y=lat, group=group), fill = '#003f5c') +
  labs( x = "Longitude", y = "Latitude") +
  annotation_scale(location = "bl", width_hint = 0.5) +
  annotation_north_arrow(location = "bl", which_north = "true", 
                         pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
                         style = north_arrow_fancy_orienteering) +
  theme_wsj()

antarctica_plot

我已经使用r:

我如何在轴上显示真实的纬度和经度值?

I've generated the following chart with R:

library(rnaturalearth)
library(rnaturalearthdata)
library(ggplot2)
library(rworldmap)
library(scales)
library(sf)
library(mapdata)
library(maptools)
library(ggthemes)

data(wrld_simpl)

antarctica <- wrld_simpl[wrld_simpl$NAME == "Antarctica", ]
pr <- "+proj=laea +lat_0=-90 +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0"
antarctica.laea <- spTransform(antarctica, CRS(pr))

antarctica_plot <- ggplot() +
  geom_polygon(data = antarctica.laea, aes(x=long, y=lat, group=group), fill = '#003f5c') +
  labs( x = "Longitude", y = "Latitude") +
  annotation_scale(location = "bl", width_hint = 0.5) +
  annotation_north_arrow(location = "bl", which_north = "true", 
                         pad_x = unit(0.75, "in"), pad_y = unit(0.5, "in"),
                         style = north_arrow_fancy_orienteering) +
  theme_wsj()

antarctica_plot

Antarctica map

How can I display the real latitude and longitude values on my axis?

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

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

发布评论

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

评论(1

庆幸我还是我 2025-02-05 13:13:06

您可以解决此操作,将空间多边形(sp)转换为简单的功能类(sf),并使用geom_sf而不是geom_polygon代码>。我找不到函数annotation_scaleannotation_north_arrow在任何这些软件包中 btw ...

antarctica.laea <- st_as_sf(antarctica.laea)
        
    ggplot(antarctica.laea) +
      geom_sf(aes(), fill = '#003f5c')+
      labs( x = "Longitude", y = "Latitude") +
      theme_wsj()

“

You can solve this transforming the spatial polygon (sp) to simple feature class (sf) and using the geom_sf instead geom_polygon. I couldnt find the functions annotation_scale and annotation_north_arrow in any of those packages btw...

antarctica.laea <- st_as_sf(antarctica.laea)
        
    ggplot(antarctica.laea) +
      geom_sf(aes(), fill = '#003f5c')+
      labs( x = "Longitude", y = "Latitude") +
      theme_wsj()

enter image description here

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