Hi Johannes, For number two, you could also use this:
?dropLayer Cheers, Lyndon On Tue, Feb 14, 2012 at 7:51 AM, Johannes Radinger <[email protected]> wrote: > 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 > > -- > > _______________________________________________ > R-sig-Geo mailing list > [email protected] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/r-sig-geo
