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

st_transform报错:CRS未找到问题求助(附Uber数据处理代码)

问题:转换Uber数据坐标系时CRS未找到错误

代码与错误信息

处理Uber出行数据时执行的代码:

dput(head(uber_data))
structure(list(Date.Time = structure(c(1396311060, 1396311420, 
1396311660, 1396312080, 1396312380, 1396312380), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), Lat = c(40.769, 40.7267, 40.7316, 
40.7588, 40.7594, 40.7383), Lon = c(-73.9549, -74.0345, -73.9873, 
-73.9776, -73.9722, -74.0403), Base = c("B02512", "B02512", "B02512", 
"B02512", "B02512", "B02512"), Time = c("00:11:00", "00:17:00", 
"00:21:00", "00:28:00", "00:33:00", "00:33:00"), Day = structure(c(1L, 
1L, 1L, 1L, 1L, 1L), levels = c("1", "2", "3", "4", "5", "6", 
"7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", 
"18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", 
"29", "30", "31"), class = "factor"), Month = structure(c(1L, 
1L, 1L, 1L, 1L, 1L), levels = c("Apr", "May", "Jun", "Jul", "Aug", 
"Sep"), class = c("ordered", "factor")), Year = structure(c(1L, 
1L, 1L, 1L, 1L, 1L), levels = "2014", class = "factor"), Hour = structure(c(1L, 
1L, 1L, 1L, 1L, 1L), levels = c("0", "1", "2", "3", "4", "5", 
"6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", 
"17", "18", "19", "20", "21", "22", "23"), class = "factor"), 
    Minute = structure(c(12L, 18L, 22L, 29L, 34L, 34L), levels = c("0", 
    "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", 
    "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", 
    "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", 
    "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", 
    "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", 
    "52", "53", "54", "55", "56", "57", "58", "59"), class = "factor"), 
    Second = structure(c(1L, 1L, 1L, 1L, 1L, 1L), levels = "0", class = "factor")), row.names = c(NA, 
6L), class = "data.frame")

uber_trip_data <-
      uber_data %>% 
      select(-`Date.Time`, -Base) %>% 
      st_as_sf(coords = c("Lon", "Lat"), crs = 4326) %>%
      st_transform(crs = 102003) %>% 
      st_coordinates() %>% 
      as.data.frame()

运行后触发错误:

Error in CPL_transform(x, crs, aoi, pipeline, reverse, desired_accuracy,  :    
crs not found: is it missing? 
In addition: Warning message: In CPL_crs_from_input(x) :   
GDAL Error 1: PROJ: proj_create_from_database: crs not found

问题原因

  1. CRS代码兼容性问题:102003是旧版ESRI投影代码,新版GDAL/PROJ库已不再直接识别纯数字格式的102003,需添加前缀或使用等效EPSG代码。
  2. 库版本差异:老旧版本的GDAL/PROJ对部分CRS代码支持不完善,无法解析目标投影定义。
  3. 拼写错误:尝试的ERSI:4326是笔误,正确格式应为ESRI:4326,但4326作为标准EPSG代码,直接使用数字即可。

解决方案

方案1:使用ESRI前缀指定CRS

修改st_transform的crs参数为带前缀的格式:

uber_trip_data <-
      uber_data %>% 
      select(-`Date.Time`, -Base) %>% 
      st_as_sf(coords = c("Lon", "Lat"), crs = 4326) %>%
      st_transform(crs = "ESRI:102003") %>% 
      st_coordinates() %>% 
      as.data.frame()

方案2:直接使用投影WKT字符串

如果前缀方式无效,可直接传入102003对应的WKT投影定义:

albers_wkt <- 'PROJCS["North_America_Albers_Equal_Area_Conic",
    GEOGCS["GCS_North_American_1983",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Albers_Conic_Equal_Area"],
    PARAMETER["False_Easting",0],
    PARAMETER["False_Northing",0],
    PARAMETER["longitude_of_center",-96],
    PARAMETER["Standard_Parallel_1",29.5],
    PARAMETER["Standard_Parallel_2",45.5],
    PARAMETER["latitude_of_center",23],
    UNIT["Meter",1]]'

uber_trip_data <-
      uber_data %>% 
      select(-`Date.Time`, -Base) %>% 
      st_as_sf(coords = c("Lon", "Lat"), crs = 4326) %>%
      st_transform(crs = albers_wkt) %>% 
      st_coordinates() %>% 
      as.data.frame()

方案3:更新地理处理库

若上述方法无效,需更新GDAL/PROJ及依赖的sf包:

# 重新安装sf包,自动更新依赖的GDAL/PROJ
install.packages("sf")

也可手动更新系统级别的GDAL和PROJ库(根据操作系统使用apt、brew或官方安装包)。

方案4:替换为等效EPSG代码

102003对应的现代EPSG代码是5070(美国本土阿尔伯斯等面积投影),可直接替换使用:

uber_trip_data <-
      uber_data %>% 
      select(-`Date.Time`, -Base) %>% 
      st_as_sf(coords = c("Lon", "Lat"), crs = 4326) %>%
      st_transform(crs = 5070) %>% 
      st_coordinates() %>% 
      as.data.frame()

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 19:30:55