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

R语言中NetCDF栅格投影转换失败问题排查

栅格重投影失败问题求助

我正在处理以下栅格图层:

class      : RasterLayer 
dimensions : 7040, 9020, 63500800  (nrow, ncol, ncell)
resolution : 1, 1  (x, y)
extent     : 0.5, 9020.5, 0.5, 7040.5  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : omi_surface_no2_2005.nc 
names      : surface_no2_ppb 
zvar       : surface_no2_ppb 

需要将其重投影后裁剪至以下Shapefile:

Simple feature collection with 1 feature and 0 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -80.24869 ymin: 43.05051 xmax: -78.43696 ymax: 44.51657
Geodetic CRS:  NAD83
                        geometry
1 MULTIPOLYGON (((-79.38536 4...

执行重投影代码omi_reproj <- projectRaster(omi, crs = crs(gtha_shp))时失败,怀疑栅格图层CRS分配错误,寻求问题解决帮助。


排查与解决步骤

  • 确认栅格实际地理范围
    当前栅格的extent为0.5, 9020.5, 0.5, 7040.5,不符合WGS84经纬度的取值范围(经纬度应为-180180、-9090),说明CRS被错误分配。OMI数据原生投影通常为正弦投影(Sinusoidal),而非WGS84经纬度。

  • 重新设置正确的CRS
    先清除错误CRS,再指定OMI原生投影:

    # 清除错误CRS
    crs(omi) <- NA
    # 设置OMI原生正弦投影
    omi_crs <- "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"
    crs(omi) <- omi_crs
    
  • 重新执行重投影
    确认矢量数据CRS正确读取后,运行重投影命令:

    # 打印矢量CRS确认
    print(crs(gtha_shp))
    # 执行重投影
    omi_reproj <- projectRaster(omi, crs = crs(gtha_shp))
    
  • 完成裁剪操作
    重投影成功后,使用crop和mask工具裁剪到目标范围:

    omi_cropped <- crop(omi_reproj, extent(gtha_shp))
    omi_cropped <- mask(omi_cropped, gtha_shp)
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.31 05:39:53