[GRASS-user] Zonal statistics with 3 maps

Hermann Peifer peifer at gmx.eu
Tue Feb 21 10:35:30 EST 2012


I am wondering how to re-produce in GRASS 6.4.2 the following data 
processing step which I have gotten in some sort of ArcGIS notation:

Population_exposed = zonalstatistics( layer1, “value”, layer2 * layer3, 
sum, # )

layer1 and layer2 are CELL, layer3 is FCELL

r.statistics doesn't seem to like floating point values, so do I really 
have to do the below steps in analogy to exercise [1], i.e. (untested):

# Create a scaled integer temp map, something like:
r.mapcalc 'temp_map = round(layer2 * layer3 * 10000)'

# Sum up per region
r.statistics base=layer1 cover=temp_map out=sum_map method=sum

# Create output in tabular format
r.stats --quiet -c layer1,sum_map | awk '{print $1, $3 / 10000}' > 

I feel that I am overlooking something which would be simpler.


[1] http://grass.osgeo.org/wiki/Vector_aggregate_values

More information about the grass-user mailing list