雷达数据重投影报错:源与目标椭球体不属于同一天体问题排查
栅格重投影报错:PROJ椭球体天体不匹配问题
现象
使用R语言terra包执行栅格重投影时,空SpatRaster可成功从stere投影转换为WGS84经纬度投影:
old_crs<-"+proj=stere +x_0=0 +y_0=0 +lat_0=90 +lon_0=0 +lat_ts=60 +a=6378.137 +b=6356.752 +units=m" a<-terra::rast(ncol = 700, nrow = 765, ext=c(-236275.403, 106985.856, 501792.127, 900792.861), crs=old_crs) newcrs="+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0" b <- terra::rast(ncols=700, nrows=765, ext=c(3.2, 7.3, 50.7, 53.7), crs=newcrs) w <- terra::project(a,b)
但替换为同参数的带数值SpatRaster时,触发报错:
Error: [project] Cannot do this transformation In addition: Warning messages: 1: In x@ptr$warp(y@ptr, "", method, mask[1], align[1], FALSE, opt) : GDAL Error 1: PROJ: proj_create_operations: Source and target ellipsoid do not belong to the same celestial body
带数值栅格参数如下:
class : SpatRaster dimensions : 765, 700, 1 (nrow, ncol, nlyr) resolution : 490.3732, 521.5696 (x, y) extent : -236275.4, 106985.9, 501792.1, 900792.9 (xmin, xmax, ymin, ymax) coord. ref. : +proj=stere +lat_0=90 +lat_ts=60 +lon_0=0 +x_0=0 +y_0=0 +a=6378.137 +b=6356.752 +units=m +no_defs source(s) : memory name : lyr.1 min value : 0 max value : 133
原因
虽然源CRS的椭球参数(a=6378.137、b=6356.752)与WGS84完全一致,但源CRS未明确指定datum或towgs84参数。PROJ在处理带数值的栅格时,会严格校验转换规则,无法识别该CRS属于地球天体,因此与明确指定地球基准的WGS84无法建立转换关系。
空栅格因无数据,PROJ跳过了严格的天体校验流程,因此能完成转换。
解决方案
方案1:重新设置源栅格的CRS,补充天体识别参数
为源CRS添加towgs84=0,0,0,明确其属于地球基准:
# 假设带数值的栅格对象名为r r <- your_numeric_raster # 更新源CRS updated_old_crs <- "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=0 +x_0=0 +y_0=0 +a=6378.137 +b=6356.752 +units=m +towgs84=0,0,0 +no_defs" crs(r) <- updated_old_crs # 执行重投影 newcrs <- "+proj=longlat +datum=WGS84 +no_defs" w <- terra::project(r, newcrs)
方案2:在project函数中强制指定源CRS
直接在投影时传入完整的源CRS参数,覆盖栅格原有CRS:
newcrs <- "+proj=longlat +datum=WGS84 +no_defs" w <- terra::project(your_numeric_raster, newcrs, source_crs = "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=0 +x_0=0 +y_0=0 +a=6378.137 +b=6356.752 +units=m +towgs84=0,0,0 +no_defs")
内容的提问来源于stack exchange,提问作者Andreas
相关产品推荐
相关产品推荐

