terra::project 中的加权和:什么是权重?

问题描述 投票:0回答:1

我使用

terra
函数将一个
terra
栅格投影到另一个不同坐标系中的
project
栅格中。
project
文档指出,对于
method="sum"
,它计算所有非 NA 贡献网格单元的加权和。我不太明白这里使用的权重:它是在投影模板栅格中计算的输入栅格的像素面积吗?还是别的什么?

sum raster projection weighted terra
1个回答
0
投票

文档不是很清楚,我也有同样的问题

method = "average"
。在这些情况下,
terra
在幕后使用
gdal_warp
,虽然GDAL文档没有提供比terra文档更多的信息,但我发现thisGithub拉取请求的评论确实有助于澄清权重是贡献细胞的区域。

以下表示也确认了它是面积加权和:

library(terra)
#> terra 1.7.55
r <- rast(nrows = 1, ncols = 3)
values(r) <- c(3,5,7)
r2 <- rast(nrows = 1, ncols = 2)

plot(r)
text(r, digits = 1)
lines(as.polygons(r2), col = "red")

r_resample <- resample(r, r2, method = "sum")
plot(r_resample)
text(r_resample, digits = 1)

#this agrees with manual area weighted sum calculation:
#left hand pixel
(3*1 + 5*0.5)
#> [1] 5.5
#right hand pixel
(5*0.5 + 7*1)
#> [1] 9.5

创建于 2023-11-16,使用 reprex v2.0.2

© www.soinside.com 2019 - 2024. All rights reserved.