[R-sig-Geo] empty brick?

Agustin Lobo alobolistas at gmail.com
Thu Jul 28 07:47:30 CEST 2011

In case of large raster objects, I understand we should make sure
that each raster layer is written to disk (so that inMemory=F) and then
make a raster stack (perhaps converting to brick to eliminate the
individual files as ulterior processing would be more efficient).

It would be more transparent if the brick could be just filled

s1 <- brick(nc=nc1, nr=nr1, nb=nb1)
for (i in 1:nb1){
r <- results of processing
s1[i] <- r


2011/7/27 Robert Hijmans <r.hijmans at gmail.com>:
>> I have a process that creates a set of (large) raster layers.
>> Does it make sense defining an empty brick object
>> and then putting each layer as band of the brick?
>> Or is it better saving each layer and then make the brick?
> Agus,
> The simplest is certainly to write single layer raster files and then make a
> RasterStack.
> To write to a single multi-layer file via the methods provided by 'raster'
> you would need to process, chunk by chunk, all layers. I.e., process the
> first chunk of all layers, and write the results to file, then move to the
> second chunk, etc. There is currently no method in 'raster', I think, that
> allows you to write the first layer, then the second, etc. But that is
> something that I could probably add if there is interest.
> There is a method for a RasterBrick that already has a file, but that is
> probably not useful here (and I do not know if it would be efficient):
> b <- brick(nc=10, nr=10, nl=10)
> b <- setValues(b, matrix(1:100, nc=10, nr=100))
> b <- writeRaster(b, 'test.tif', overwrite=T)
> b <- update(b, v=100:1, cell=1, band=2)
> plot(b, 1:3)
> Best, Robert
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/empty-brick-tp6622064p6627540.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

More information about the R-sig-Geo mailing list