You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻找map_data('world')替代方案:覆盖南纬-90的南极地图数据集

推荐解决方案:使用rnaturalearth包的世界地图数据集

这是目前R生态中最常用的map_data('world')替代方案,数据集自带的南极洲范围覆盖至南纬-89.99,完全适配ggplot2绘图逻辑,操作门槛极低。

操作步骤

  • 第一步:安装依赖包
install.packages(c("rnaturalearth", "rnaturalearthdata"))
# 如果需要更高精度的边界数据,可额外安装 rnaturalearthhires 包
  • 第二步:加载数据并绘图
library(ggplot2)
library(rnaturalearth)
library(sf)

# 获取中等精度的世界国家矢量数据,返回sf格式可直接对接ggplot2
world <- ne_countries(scale = "medium", returnclass = "sf")
# 测试点位
data <- data.frame(lat = -86, long = 0)

# 绘图,无需手动指定group参数,适配所有ggplot2的图层逻辑
ggplot() +
  geom_sf(data = world, col = "grey", fill = NA) +
  geom_point(data = data, aes(y = lat, x = long), col = 'red')

兼容原有写法的转换方案

如果需要沿用原来map_data返回的普通数据框格式(非sf空间格式),可通过以下代码转换,完全兼容你原有geom_polygon的写法:

world_df <- world %>% 
  st_coordinates() %>% 
  as.data.frame() %>% 
  rename(long = X, lat = Y, group = L2)

你可以通过以下代码验证南极洲的最低纬度:

world %>% 
  filter(admin == "Antarctica") %>% 
  st_coordinates() %>% 
  as.data.frame() %>% 
  pull(Y) %>% 
  min()
# 返回结果约为-89.9999,完全覆盖南纬-90附近的点位需求

内容的提问来源于stack exchange,提问作者MorrisseyJ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 06:48:04