Skip to content
Prev 23749 / 29559 Next

Take mean of list of raster stacks

Hi Thiago,?




Done in haste, but I think this might do it (it?s on an 8X8 problem though):?





stlist <- lapply(1:8, function(x) {

?rl <- stack(lapply(1:8, function(y) {

? ?r <- raster(nrow = 10, ncol = 10)

? ?r[] <- sample(1:100, size = ncell(r), replace = TRUE)

? ?r

?}))

?rl

})

names(stlist) <- paste0("s", 1:8)




stack(lapply(1:8, function(x) {

? calc(stack(lapply(1:8, function(y) stlist[[y]][[x]])), mean)

}))




Hope this helps.?




Cheers, Lyndon




?
Sent from Mailbox

On Wed, Dec 2, 2015 at 9:23 AM, Thiago V. dos Santos
<thi_veloso at yahoo.com.br> wrote: