[R-sig-Geo] raster package - zonal - standard deviations
Rafael Wüest
rafael.wueest at wsl.ch
Mon Nov 5 16:35:25 CET 2012
Hi Christian
What version of raster do you use. Using my installation of raster (version 2.0-12), 'sd' as a function in zonal works fine (see example below).
r <- raster(ncols=10, nrows=10)
r[] <- runif(ncell(r)) * 1:ncell(r)
z <- r
z[] <- rep(1:5, each=20)
zonal(r, z, 'sd')
zone "sd"
[1,] 1 4.894058
[2,] 2 9.216353
[3,] 3 14.144341
[4,] 4 19.973913
[5,] 5 27.934773
I guess updating the raster package will solve the problem.
Best,
Rafael
On 02.11.2012, at 18:35, Christian Levers wrote:
> Hello,
>
> I am using the raster package to calculate zonal statistics for my stack of ca. 50 rasters (each raster is about 33 mio. pixels) and I am wondering if there is a simple way to calculate standard deviations for the zones since "sd" is not implemented in the presets for the "stat" argument. If not, I guess defining a function which calculates std.dev is the easiest solution.
>
> Thanks in advance and a nice weekend,
> Christian
>
> --
> MSc Geogr. Christian Levers
> Doctoral Researcher
>
> Biogeography & Conservation Biology
> Geography Department | Humboldt-Universitaet zu Berlin
>
> eMail: christian.levers at geo.hu-berlin.de
> phone: +49 (0) 30 2093 9341
> fax: +49 (0) 30 2093 6848
> mail: Unter den Linden 6 | 10099 Berlin | Germany
> web: http://www.geographie.hu-berlin.de
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland
+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest/index_EN
More information about the R-sig-Geo
mailing list