[R-sig-Geo] RasterBrick questions
Johannes Radinger
JRadinger at gmx.at
Tue Feb 14 13:51:15 CET 2012
Dear R-sig-geo List!
I have two little questions concerning RasterBricks from the Raster package.
1) I have a list of several rasters (programmatically created during a loop)
which I want to transform into a RasterBrick. Here an example:
library(raster)
r1 <- r2 <- r3 <- raster(nrow=10, ncol=10)
values(r1) <- runif(ncell(r1))
values(r2) <- runif(ncell(r2))
values(r3) <- runif(ncell(r3))
#Thats how the loops collects the rasters into the list:
ls <- list()
ls[["r1"]] <- r1
ls[["r2"]] <- r2
ls[["r3"]] <- r3
ls
How can I transform ls into a RasterBrick? Or is there any function to append a new layer to a RasterBrick during each run of the loop (instead of collecting the results in a list of rasters)?
2) If I have a final RasterBrick, is there a simple way to exclude a single layer, resp. remove it? I am looking for something like indexing?
b <- brick(r1,r2,r3)
# e.g. something like: b[b!="r2"]
Best regards,
/johannes
--
More information about the R-sig-Geo
mailing list