Skip to content
Prev 27777 / 29559 Next

raster: stackApply problems..

Hi Leonidas,

both results are in the same order, but the name is different.
You can rename the first as in the second:
names(res) <- names(res2)

I provided an example to help you understand the logic.

library(raster)
beginCluster(2)
r <- raster()
values(r) <- 1
# simple sequential stack from 1 to 6 in all cells
s <- stack(r, r*2, r*3, r*4, r*5, r*6)
s
res <- clusterR(s, stackApply, args = list(indices=c(2,2,3,3,1,1), fun =
mean))
res
res2 <- stackApply(s, c(2,2,3,3,1,1), mean)
res2
dif <- res - res2
# exatly the same order because the difference is zero for all layers
dif
# rename
names(res) <- names(res2)

Best regards,

Frederico Faleiro

On Tue, Nov 19, 2019 at 4:15 PM Leonidas Liakos via R-sig-Geo <
r-sig-geo at r-project.org> wrote: