This is a dirty way of doing it possibly being inefficient for large
rasters. I'm sure Robert will serve you a slick and fast solution shortly.

library(raster)
r <- raster(nrow=5, ncol=5)
s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3) )) )

# first argument is stack names, second argument is a list of RasterStacks,
and then a function
mapply(as.list(c("stack_a", "stack_bb", "stack_c")), list(s, s, s), FUN =
function(x, y) {
  per.stack <- sapply(1:nlayers(y), function(ly, stack.data) {
    res <- stack.data[[ly]][]
    data.frame(min = min(res), max = max(res), mean = mean(res))
  }, stack.data = s, simplify = FALSE)
  per.stack <- do.call("rbind", per.stack)
  per.stack$layer <- names(y)
  per.stack$stack <- x
  per.stack
})

Cheers,
Roman


On Thu, Dec 12, 2013 at 11:11 PM, Eddie Smith <eddieatr@gmail.com> wrote:

> Hi guys,
>
> library(raster)
> r <- raster(nrow=5, ncol=5)
> s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3) )) )
>
> class       : RasterStack
> dimensions  : 5, 5, 25, 5  (nrow, ncol, ncell, nlayers)
> resolution  : 72, 36  (x, y)
> coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5
> min values  : -4.2962007, -2.6573262, -1.3929480,  0.1079140, -0.1711899
> max values  :   5.888370,   7.654831,  10.222458,  10.486516,   9.694796
>
> How do I export the minimum and maximum values for all layers? (I have few
> hundreds of layers in a rasterstack). Is it also possible to get the mean
> values?
>
> Thank you.
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
In God we trust, all others bring data.

	[[alternative HTML version deleted]]

