Stavana,

You can extract individual layers from a RasterStack or RasterBrick 's'
like this:
subset(s, 3)
or:
s[[3]]

if you have three RasterStack/Brick objects x80, x81, x82, you could do

mean1 <- mean(x80[[1]], x81[[1]], x82[[1]])
mean2 <- mean(x80[[2]], x81[[2]], x82[[2]])
etc

But it would perhaps be more elegant to compute the means for all 19 layers
in one step:

mean8082 <- (x80 + x81 + x82) / 3

Robert

On Thu, Jul 26, 2012 at 10:03 AM, Stavana <stavanastrutz@gmail.com> wrote:

> Hi listmembers,
>
> I've constructed rasterbricks of the 19 bioclimatic variables (using the
> biovars method) for each year in the United States from 1980-2011 and I'd
> like to calculate that mean of each bioclim variable over a particular
> temporal range. I need to loop through each layer of the rasterbrick for a
> set of years and get the mean.
>
> For example, I'd like to calculate the mean of bioclim1, then 2, then 3,
> then 4, etc. for the years 1980-89 and store those averages in a new raster
> brick or set of raster layers. I know there has to be a way to loop through
> each layer of a raster brick or extract corresponding layers from different
> bricks but I'm having difficulty locating an example of how to do so.
>
> I'm also curious as to the exact difference between a raster stack and a
> raster brick, I've read the definition in Hijmans Raster package manual but
> still do not understand the precise difference.
>
> Any code help would be much appreciated as would suggestions of other web
> resources or books on the subject. I generally work in ArcGIS but am trying
> out R because it seems a bit faster in some of its raster processing
> capabilities.
>
> Thank you,
> Stavana Strutz
> University of Texas at Austin
>
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/Raster-Brick-Iteration-tp7580616.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

