我有 29 个具有以下属性的栅格图块:
class : SpatRaster
dimensions : 45000, 45000, 1 (nrow, ncol, nlyr)
resolution : 0.0008888889, 0.0008888889 (x, y)
extent : 20, 60, -40, 0 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs
data source : N00E020_agb.tif
names : N00E020_agb
我想将所有 29 个图块合并到一个栅格中,但是,在这种高分辨率下需要很长时间。所以我首先使用聚合降低了这些栅格的分辨率。我汇总了 113 倍(大致导致分辨率为 0.1):
pathz <- "C:/Users/rastertiles/" # directory where raster tiles are located
filez <- list.files(path = paste(pathz, sep = ""), pattern = ".tif") # list all files in directory
r.list_113 <- list() # make an empty list
for(i in 1:length(filez)){
tmp1 <- rast(paste(pathz, filez[i], sep = ""))
tmp1 <- terra::aggregate(tmp1,fact=113, fun="mean", na.rm=TRUE) # aggregate by a factor 113.
r.list_113[[i]] = tmp1
}
但是,虽然原始图块都具有相同的原点 ([0,0]),但在使用“聚合”后,新栅格的原点存在细微差异:
> lapply(r.list_113, origin)
[[1]]
[1] 0.01155556 0.00000000
[[2]]
[1] 0.03466667 0.00000000
[[3]]
[1] -0.04266667 0.00000000
[[4]]
[1] -0.01955556 0.00000000
(...)
然后,当我尝试将新栅格与 'merge' 合并时,出现错误:
> m_113X <- do.call(terra::merge, r.list_113X)
Error: [merge] origin of SpatRaster 2 does not match the previous SpatRaster(s)
欢迎任何我应该做的建议。