我有两个SpatRaster,我想合并。当他们合并时,我希望每个像素从两个光栅的值求和。我已经尝试了以下代码,但它不工作。我该怎么做?
abd_projected <- project(abd_Americas, crs, method = "near")
abd2_projected <- project(abd2_Americas, crs, method = "near")
class(abd_projected)
[1] "SpatRaster"
attr(,"package")
[1] "terra"
class(abd2_projected)
[1] "SpatRaster"
attr(,"package")
[1] "terra"
merged_abd <- merge(abd_projected, abd2_projected fun = sum )
Error: unexpected symbol in "merged_abd <- merge(abd_projected,
abd2_projected fun"
merged_abd <- merge(abd_projected, abd2_projected, FUN = sum )
Error: [sprc] list elements should be 'SpatRaster'
is of class: function
我也试过
mergedABD <- raster::merge(abd_projected, abd2_projected,
tolerance=0.1)
和
abdall_projected<- c(abd_projected, abd2_projected)
rsum <- app(abdall_projected, sum)
都不管用
如果有帮助的话,我试图合并的数据是来自ebirdst软件包的物种数据。我想在绘制它们之前合并两个物种丰度空间(栅格)数据集。
1条答案
按热度按时间fquxozlt1#
您可以使用
mosaic
,这样您就可以将"sum"
指定为用于计算重叠像素中的像素值的函数。