A couple days ago I posted the following question:
I want to get some statistics that r.stats can't directly come up
with, and I'm wondering if there is another function to do the trick.
I have two raster maps: one has polygons defining different "landscape
units". The second is a crop yield "surface" from the same area.
I want to know, for each landscape unit, not simply the total area,
but also the mean yield, and standard deviation, etc. So I need a
routine that uses the landscape units map as a "mask", and calculates
descriptive statistics from the raster values of the yield map found
within the area of each polygon.Any suggestions?
I got several suggestions. Thanks to those who responded. The kinds
of suggestions and/or ideas I came up with were:
A) Get the raw statistics using r.stats, then transfer these to a
spreadsheet. This suggestion misunderstands the question, in that
I wanted a "direct" way of getting the mean and standard deviation,
without the extra human processing. We're looking for a single
command line here.
B) Write a script to do the job, taking the raw data from r.stats.
Susan Huse (sue@ced.berkeley.edu) sent me a great gawk script that
only needs a little tweaking to do the job. Thanks, Sue; I might
even learn a little gawk this way.
C) I am tempted to modify r.average so that it gives not only the mean,
but also standard deviation. A fun little exercise in GRASS programming.
But I probably won't get around to it because ....
D) Bill Baker (BAKERWL@UWYO.EDU) has written the r.le tools, which
do exactly what I want and much more. Specifically, Bill assures
me the task I want to do requires the command:
r.le.pixel map=crop_yield sam=r reg=landscape_units att=b1,b2,b3,b4
The r.le tools are in rle21.tar.Z in the incoming directory on the
"moon" ftp server. They do much more than simple stats, so much more
that I forgot they also do these simple things. Thanks, Bill!
Tim.