I have a list
of raster stacks
that each raster stack contains unequal number of rasters. How can I sum up number of rasters in my list? I have tried length()
but this only returns number of stacks in my list!
example data:
library(raster)
#reproducible example
set.seed(987)
#our list of rasters
r.lst <- as.list(1:3)
# setting up list pf raster stacks
r1 <- raster(nrows = 1, ncols = 1, res = 0.5, xmn = -1.5, xmx = 1.5, ymn = -1.5, ymx = 1.5, vals = runif(36, 1, 5))
r.lst[[1]] <- stack(lapply(1:7, function(i) setValues(r1,runif(ncell(r1)))))
r.lst[[2]] <- stack(lapply(1:3, function(i) setValues(r1,runif(ncell(r1)))))
r.lst[[3]] <- stack(lapply(1:2, function(i) setValues(r1,runif(ncell(r1)))))