R语言加载意大利GeoJSON地图报错求助:sp::CRS参数错误
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")
2. Switch to the Modern sf Package (Recommended)
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

