[R-sig-Geo] empty brick?

Robert Hijmans r.hijmans at gmail.com
Wed Jul 27 22:15:04 CEST 2011


> 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.



More information about the R-sig-Geo mailing list