[STATSGRASS] R - GRASS and r.reclass

Roger Bivand Roger.Bivand at nhh.no
Thu Dec 18 03:46:42 EST 2003


On Thu, 18 Dec 2003, Hamish wrote:

> > I've done some very simple scripts to execute repeated operations on
> > 25 GRASS maps. The problem is to pass values of reclassification rules
> > to r.reclass. I've tried:
> 
> [...]
> 
> > But this doesn't work. I think that this could be also with a bash
> > script, but I don't know anything about bash.
> 
> 
> It is actually pretty clean with Bash, try the attached.

Yes, this does it, and could be written to a file from within R too. My 
guess is that writing to a pipe to the shell could do it too, I'll have a 
look. It's difficult to include in the examples, because they now run 
without GRASS in their own temporary location. I'll post again when I've 
found a route from within R.

Best wishes,

Roger

> 
> 
> regards,
> Hamish
> 
> 
> 
> #!/bin/bash
> #  reclass script
> 
> i=1
> while [ $i -le 25 ] ; do
> 
>     r.reclass input=imagen$i output=imarec$i << EOF
>        253 = 192
>        252 = 96
>        251 = 48
>        250 = 24
>        249 = 12
>        221 = 8
>        193 = 7
>        165 = 6
>        133 = 4
>        102 = 3
>        70 = 2
>        39 = 1
>        * = NULL
>        end
> EOF
> 
>     i=`expr $i + 1`
> done
> 
> 
> 
> 
> # if you want the maps to be 01,02,03,..,09,10,11 add this line:
> # MAP=`echo $i | awk '{printf "%02i", $1}'`
> # echo $MAP
> 
> _______________________________________________
> statsgrass mailing list
> statsgrass at grass.itc.it
> http://grass.itc.it/mailman/listinfo/statsgrass
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the grass-stats mailing list