Thanks Roman and Andrew.

For a rasterstack with 365 layers and 1,500,000 number of cells

> system.time(min <- cellStats(stack1982, 'min'))
   user  system elapsed
2930.36  581.09 5005.70




On Fri, Dec 13, 2013 at 12:44 AM, Andrew P Vitale <vitale232@gmail.com>wrote:

> I think this is what you're going for:
>
>
> library(raster)
> r <- raster(nrow=5, ncol=5)
> s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3) )) )
>
> min <- cellStats(s, 'min')
> max <- cellStats(s, 'max')
> mean <- cellStats(s, 'mean')
>
> df <- data.frame(min, max, mean)
>
> write.csv(df, 'df.csv')
>
>
> On 12/12/2013 2:11 PM, Eddie Smith 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
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

