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

R语言加载意大利GeoJSON地图报错求助:sp::CRS参数错误

Fixing the unused argument (SRS_string = from$wkt) Error When Loading Italian Map in R

Hey Antonella, let's get this sorted out quickly! That error you're seeing happens because your version of the sp package is out of date. The SRS_string parameter was added to sp::CRS() in version 1.4-0 of the package, so older versions don't recognize it—hence the error when geojsonio tries to parse the coordinate system from the GeoJSON file.

Here are two straightforward solutions:

1. Upgrade the sp Package

This is the direct fix for the error you're getting. Just update sp to its latest version:

# Remove the old version if needed
remove.packages("sp")
# Install the latest stable version
install.packages("sp")
# Reload the packages and run your original code
library(sp)
library(geojsonio)
map <- geojson_read("https://raw.githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_provinces.geojson", what="sp")

These days, the sf package is the standard for geospatial work in R—it's more intuitive, has better compatibility with modern data formats, and avoids many of the quirks of the older sp ecosystem. Here's how to load your Italian provinces map with sf:

# Install and load sf
install.packages("sf")
library(sf)
# Read the GeoJSON directly as an sf object (the modern standard)
map_sf <- st_read("https://raw.githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_provinces.geojson")

# If you absolutely need an sp object (for legacy code), you can convert it:
library(sp)
map_sp <- as(map_sf, "Spatial")

If you run into dependency issues while upgrading sp, going with sf is definitely the better long-term choice—it's actively maintained and has a much more user-friendly interface for geospatial tasks.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.11 08:11:06