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

如何在新版R中替代GADMTools制作自定义Shapefile?

替代GADMTools的R空间数据处理方案

方案1:使用sf + giscoR

giscoR提供欧盟官方地理边界数据,适配新版R,配合sf(当前R空间数据处理标准包)可完成需求:

  1. 安装并加载依赖包
install.packages(c("sf", "giscoR"))
library(sf)
library(giscoR)
  1. 获取指定国家边界并合并
# 目标国家ISO3代码与旧代码一致
target_countries <- c("RUS","LTU","LVA","EST","FIN", "POL","BLR")
# 获取ADM0级别国家边界
country_shapes <- gisco_get_countries(country = target_countries)
# 合并所有国家图层
joinmap <- do.call(rbind, country_shapes)
  1. 裁剪指定区域
# 裁剪范围参数与旧代码一致
studyarea <- st_crop(joinmap, xmin=19, ymin=50, xmax=25, ymax=56)
  1. 导出ArcGIS兼容的Shapefile
# 替换为你的目标路径
st_write(studyarea, "path_for_shapefile/studyarea.shp", driver = "ESRI Shapefile")

方案2:使用sf + rnaturalearth

rnaturalearth提供开源全球地理数据,适配新版R,覆盖范围广:

  1. 安装并加载依赖包
install.packages(c("sf", "rnaturalearth", "rnaturalearthdata"))
library(sf)
library(rnaturalearth)
  1. 获取指定国家边界并合并
target_countries <- c("RUS","LTU","LVA","EST","FIN", "POL","BLR")
# 获取ADM0级别国家边界,返回sf格式对象
country_shapes <- ne_countries(country = target_countries, returnclass = "sf")
joinmap <- country_shapes
  1. 裁剪指定区域
studyarea <- st_crop(joinmap, xmin=19, ymin=50, xmax=25, ymax=56)
  1. 导出Shapefile
st_write(studyarea, "path_for_shapefile/studyarea.shp", driver = "ESRI Shapefile")

注意事项

  • sf包支持所有现代R版本,功能覆盖空间数据处理全流程,可替代GADMTools完成更多操作
  • 导出的Shapefile包含完整属性信息,可直接在ArcGIS中加载使用
  • 若需要细分行政边界(如州/省级别),可在gisco_get_countries或ne_countries中指定level参数(如level = 1对应一级行政区)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 01:46:33