[GRASSLIST:2758] Re: Reclassify with r.stats and awk

Hamish hamish_nospam at yahoo.com
Thu Feb 26 01:39:47 EST 2004


> I tried to reclassify a grid map. However, instead of getting the 
> category labels, I get zeros. You see the problem here:
> 
> GRASS 5.0.2 > r.stats -l in=rt.rmris.ct.r
> r.stats:  100%
> 19564 TSF
> 19578 TSF
> 19642 GRA
> 19657 TSF
> 19680 GRA
> 19719 TSF
> 19736 TSF
> 19738 TAA
> ...
> 
> That's what I expect to get.
> 
> GRASS > r.stats -l in=rt.rmris.ct.r | awk '{printf "%d=%d\n", $1, $2}'
> r.stats:  100%
> 19564=0
> 19578=0
> 19642=0
> 19657=0
> 19680=0
> 19719=0
> 19736=0
> 19738=0
> ...
> 
> Why is the second column replaced by zeros? Do I need first to replace 
> the category labels with e.g. integer values?
> 
> Thanks for any help!

%d means decimal means integer value. You want %s for string.
 (C programming convention)


Try: 

 ... | awk '{printf "%d=%s\n", $1, $2}'



Hamish




More information about the grass-user mailing list