[GRASSLIST:2912] Reclassification problem (string with spaces)

Christof Bigler christof.bigler at colorado.edu
Thu Mar 11 13:11:36 EST 2004


Hi Grass list

I encountered once again some problems with the reclassification of a 
raster map. The map has three category descriptions:
"Burned", "Burned but surviving", "Unburned". The following problem 
occurs because of the spaces in "Burned but surviving".

When I try to do the following:
r.stats -l in=wr.sud.5.bd.r | cut -d" " -f2 | sort | uniq | awk '{print 
$1,NR}' > wr.sud.5.bd.r.recl

I get only the following two categories:
Burned 1
Unburned 2

which is not a big problem, since I just have to add the missing 
category:
Unburned 1
Burned but surviving 2
Burned 3

I then write a new reclassification rule:
r.stats -l in=wr.sud.5.bd.r | awk 'BEGIN{while((getline line < 
"wr.sud.5.bd.r.recl") > 0){split(line,A," ");R[A[1]]=A[2] }}{print 
$1,"=",R[$2],$2}' > wr.sud.5.bd.r.recl2

cat wr.sud.5.bd.r.recl2
34 = 1 Unburned
81 = 1 Unburned
87 = 1 Unburned
96 = 3 Burned
97 = 3 Burned
102 = 1 Unburned
...

This looks ok, except of CAT_ID which should be "97 = 2 Burned but 
surviving". Again, I could change this manually, but this could be kind 
of tedious, particularly with long lists.
Is there a way to prevent that strings with spaces between words are 
cut?

Thanks for your help.

Christof




More information about the grass-user mailing list