[GRASS5] r.average, r.statistics

Aleksey Naumov naumov at acsu.buffalo.edu
Sun Mar 3 19:36:53 EST 2002


Glynn,

> You can extract the landuse/average-slope table from the computed
> landuse.slope map with:
>
> r.stats -1gn landuse | awk '{print $1,$2}' | r.what
> input=landuse,landuse.slope | awk -F'|' '{print $4,$5}' | uniq | sort |
> uniq
>
> This is significantly less efficient (and more cumbersome) than the
> original r.average.

Thanks for your help! This is the scariest-looking piece of GRASS/UNIX magic 
I ever used, but it does the job (aside from the fact that it sorts landuse 
values as strings, not numerically). I'll have to remember this for when I 
want to impress somebody :-) Seriously, though, this is something to fall 
back on, but I'd rather have r.statistics work properly (see below).

> > Is r.statistics supported though? I tried using it for the problem above,
> > it complained that r.stats doesn't accept <z> flag. Changed line 29 of
> > src/raster/r.statistics/cmd/o_average.c
> > from
> > 	sprintf (command, "%s -az input='%s,%s' fs=space > %s", ...
> > to:
> > 	sprintf (command, "%s -an input='%s,%s' fs=space > %s", ...
> >
> > Now I can run it:
> > GRASS:~ > r.statistics base=landuse cover=slope method=average
> > output=landuse.slope1
> >
> > but the output map 'landuse.slope1' is totally wrong. r.report says that
> > all it's cells are null, and r.info seems to get stuck in a loop and
> > needs Ctrl-C.
>
> If I try this using the landuse and slope maps from the "spearfish"
> dataset, it works. r.info doesn't produce useful information, but
> r.cats does.

Yes, I just found out that r.statistics works fine when cover is CELL, but it 
generates a null map when cover is a FCELL map. Try this in spearfish:

r.slope.aspect elevation=elevation.dem slope=slope.f format=percent
r.statistics base=landuse cover=slope.f method=average output=landuse.slope

Then landuse.slope is all null as shown by r.report.

Obviously, it's a bug in r.statistics. I'll try to look at it, but would 
appreciate any hints...

> I'll commit the "-z/-n" fix to r.statistics.

Thanks.

Aleksey



More information about the grass-dev mailing list