[GRASSLIST:418] Re: a huge matrix ?
H Bowman
hamish_nospam at yahoo.com
Wed Jun 18 02:43:43 EDT 2003
> >The most straightforward approach (although not particularly
> >efficient), would be to use an iterative approach, i.e.
> >
> > n=0
> > last='null()'
> > while read a1 a2 a3 a4 a5 a6 a7 a8 ; do
> > result=pr2.pass$n
> > r.mapcalc "$result = if (f28geo5==$a1 && f28slpcat==$a2 && f28concavity==$a3 && n_facing==$a4 && road_bas==$a5 &&str_buf==$a6 && f28f4==$a7, $a8, $last)"
> > last=$result
> > done < rules.txt
> >
> >where rules.txt looks like:
> >
> > 21 6 1 1 1 1 0 701.22
> > 7 4 2 1 1 2 1 702.06
> > ...
> >
>
> Firstly I intend to try your iterative way.
> In that, doesn't n have any increament ?
> something like n=n+1 in the loop.
> If so,Doesn't it mean creating a new map - totally 10500 map- in every
> iteration
Not sure if this is what you are after, but as a general iterative bash scripting template:
n=0
r.mapcalc patchmap="null()"
while read a1 a2 a3 a4 a5 a6 a7 a8 ; do
echo "Pass $n .."
r.mapcalc ...
r.patch out=patchmap in=patchmap,pr2.pass$n (?? r.mapcalc sum=sum+new ..)
g.remove rast=pr2.pass$n
n=`expr $n + 1`
done
actually for that n isn't needed, but still a good idea.
Hamish
More information about the grass-user
mailing list