[GRASS5] r.average, r.statistics

Aleksey Naumov naumov at acsu.buffalo.edu
Sun Mar 3 21:52:01 EST 2002


Thanks again, Glynn. 

I see what you're suggesting (also had some time to look at the code to see 
where the problem is). However, I hesitate to do a quick hack, just to get 
'r.statistics ... method=average' working for FCELL maps. 
For now I'll simply convert my slope map to CELL. When I get a little time, 
I'll look at r.statistics in more detail and try to modify it to work with 
FCELL/DCELL. 

Aleksey


> It's basically an artifact of the way that r.statistics works.
> r.statistics invokes r.stats with the base and cover maps, then
> processes the output using the fact that r.stats' output is sorted in
> order of the categories from the first map (the base map).
>
> r.stats essentially works on categories. With an FP map, it partitions
> the map's range into bands, and treats each band as a category. The
> output format shows the band's range instead of an individual value,
> and this confuses r.statistics.
>
> To get FP maps to work, start by changing the r.stats command from
> something like:
>
>     sprintf (command, "r.stats -an input='%s,%s' fs=space > %s",
> 	basemap, covermap, tempfile1);
>
> to something like:
>
>     sprintf (command, "r.stats -1n input='%s,%s' fs=space | sort -n | awk
> '{print $1,$2,1}' > %s", basemap, covermap, tempfile1);
>
> You will also need to change the processing loop to use float/double
> instead of integer for the second column ("covercat" variable).



More information about the grass-dev mailing list