[GRASS-user] split adjacent categories

Martin Wegmann wegmann at biozentrum.uni-wuerzburg.de
Fri Jan 11 10:25:56 EST 2008


On Thursday 10 January 2008 20:17:24 Patton, Eric wrote:
> >thanks - I added it but the first part:
> >
> >COUNTER = 1
> >
> >already caused
> >
> >COUNTER: command not found
> >
> >can this bash scripting be used in GRASS like that at all?
> >
> >Martin
>
> Try getting rid of the extra spaces around the assignment statement:
>
> COUNTER=1

thanks everybody - now it's working:


#!/bin/bash

 echo -n "input:"
 read input
 
 r.to.vect $input output=tttemp feature=area --o
 v.to.rast tttemp output=tttemp_in use=cat --o
 
 g.remove vect=tttemp

max=`r.info -r "tttemp_in" | grep max | cut -f2 -d=`
 
COUNTER=`r.info -r "tttemp_in" | grep min | cut -f2 -d=`
 
# while [  $COUNTER -lt $max ]; do
while [ "$COUNTER" -le "$max" ]; 

do
        echo counter ist "$COUNTER"
        
        r.mapcalc "tttemp_1 = if(tttemp_in == "$COUNTER",1,null())"
 
        r.mapcalc "tttemp_inv = if(isnull(tttemp_1),1,null())" >/dev/null 2>&1
        r.buffer input=tttemp_inv output=tttemp_buffer distances=100 --o
        r.mapcalc "tttemp_area."$COUNTER" =if(isnull(tttemp_buffer),1,null())"
 
        let "COUNTER=COUNTER+1"
 
done


var1=1

var2=0

# until [ "$var1" -eq "$max" ]

while [ "$var1" -le $max ]


do
        echo "$var1" plus "$var2"
        r.mapcalc "tttemp_area.0 = tttemp_area.1"
        r.patch input=tttemp_area.$var1,p.$var2   output=p."$var1" --o
    
        var1=$(( $var1 + 1 ))
        var2=$(( $var2 + 1 ))
done


More information about the grass-user mailing list