Johannes,
If you have separate files that you want to combine into a single object, I
would generally create a RasterStack, particularly if you want to add or
remove layers.
e.g. stack(ls)
Creating a RasterBrick may involve, for large datasets, writing a new
multi-layer file to disk and that can take much time. When you remove a
layer from a RasterBrick that has its values on disk, a RasterStack is
returned because you would have to write a new file to get a new
RasterBrick object. For large (on disk) datasets, RasterBrick is best for
existing multi-layer files, RasterStack best for dealing with seperate
files, or with a subset of layers ("bands") from a multi-layer file.
Robert
On Tue, Feb 14, 2012 at 5:50 AM, Etienne B. Racine <[email protected]>wrote:
> Johannes,
>
> 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)?
> >
> That is pretty much the representation of a brick, so I'm not sure you'd
> gain anything. Simply :
> b <- brick(ls)
>
>
> >
> > 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"]
> >
> > I tend to use something like :
> rl <- list(r1, r2, r3)
> names(rl) <- c("soil", "veg", "hydro")
> b <- brick(rl)
> # Now you can make selections e.g.:
> plot(b[[c("soil", "hydro")]])
>
> Note that b[[ with two elements returns a stack (not sure why), so you
> might want to re-brick it depending of your needs.
>
> Etienne
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> 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