How to loop through raster brick?
问题 I have a raster brick of SCA(nrow=108,ncol=132,nlayers=365) which contains fractional snow cover. I want to make 46 stacks each of 8 layers from this and calculate maximum fractional snow cover from these 46 stacks.How can i do this? 回答1: I think you may want to do that this way: library(raster) # example data sca <- brick(nrow=108,ncol=132,nl=365) values(sca) <- runif(ncell(sca)*nlayers(sca)) # indices grouping sets of 8 i <- rep(1:ceiling(365/8), each=8) # the last period is not a complete