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

R中为多环境变量raster::stack分配CRS及解决提取坐标警告

栅格坐标提取时的警告问题排查

我有一个raster stack,包含从netCD4文件导出的平均海表温度、平均海表盐度和平均叶绿素a栅格,同时使用GEBCO文件计算了深度、坡度以及海豚到珊瑚礁的距离。尝试从环境变量raster::stack对象env中提取coords_dolphin对象的坐标时,出现如下警告:

Warning message:
attribute variables are assumed to be spatially constant throughout all geometries

我怀疑问题根源是raster stack中的所有栅格图层和数据点未统一使用EPSG:4326坐标系。因数据所有权限制,无法共享数据。

以下是我的代码:

# 将数据框转为CRS为4326的sf空间对象
coords_dolphins <- st_as_sf(x=MyDf, coords = c("Longitude_E", "Latitude_N"), crs = 4326)

# 将预测变量合并为raster stack对象
env <- stack(resampled_sss, resampled_sst, resampled_chla, depth, slope, distance)
plot(env)

# 重命名环境预测变量
names(env) <-c("SSS", "SST", "Chlor-a", "Depth", "Slope", "Distance")

# 确保栅格stack的CRS与坐标一致
crs(env) <- crs('+init=EPSG:4326')

# 提取env范围内的海豚坐标
xy <- st_intersection(coords_dolphins, st_as_sfc(st_bbox(env)))

xy的输出结果:

Simple feature collection with 707 features and 33 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 33.69052 ymin: 27.15528 xmax: 33.98925 ymax: 27.85163
Geodetic CRS: WGS 84

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 12:07:46