[R-sig-Geo] Any reason to not use brick() on a single-band raster?

Robert J. Hijmans rhijmans at ucdavis.edu
Fri Oct 18 23:49:17 CEST 2013


Jonathan,
I do not thing it would matter much. But there are a few functions
that only work on for a RasterLayer (e.g. focal, distance); so you
would need to coerce the object to a RasterLayer first to use these.
The raster package started with RasterLayer and RasterStack.
RasterBrick was added later. You could argue that this made
RasterLayer obsolete and perhaps it is about time to start
de-emphasizing RasterLayer, i.e. have functions return RasterBrick
objects even if there is only 1 layer, such as you are proposing to
do.
Robert

On Fri, Oct 18, 2013 at 1:16 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote:
> R-sig-geo'ers:
>
> I was curious: is there any practical reason to not use brick() on a
> single-band raster (efficiency hits, for instance)?  The reason I'm
> asking is that I'm working on some functions that return a single or a
> multi-band output, and rather than doing an if(nlayers(x)==1)
> raster(x) else brick(x); I was going to make it easier and just always
> returning brick(x).
>
> --j
>
> --
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> Department of Geography and Geographic Information Science
> University of Illinois at Urbana-Champaign
> 259 Computing Applications Building, MC-150
> 605 East Springfield Avenue
> Champaign, IL  61820-6371
> Phone: 217-300-1924
> http://www.geog.illinois.edu/~jgrn/
> AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Robert J. Hijmans
Associate Professor, Department of Environmental Science and Policy
University of California, Davis
2001 Wickson Hall
(530) 752-6555



More information about the R-sig-Geo mailing list