Hi, To get around the ' or " problems when scripting for r.mapcalc I prefer to use another syntax construction that goes like this:
echo "river = if(river == $old, $new, null())" | r.mapcalc That way you evaluate the variables $old and $new before sending it to r.mapcalc. cheers Daniel On Thu, Mar 5, 2009 at 11:42 AM, achim <[email protected]> wrote: > Hi, > > did someone tried -like me- to use r.mapcalc in a script inside an > do-while-clause? > > I cannot pass changing variables $old, $new like: > r.mapcalc 'river=if(river=$old,$new,null())' > its because of the '', which are needed because if the if-statement. > I failed passing the hole statement eg. 'river=if(river=5,4,null())' as > a variable like: > r.mapcac $statement > ... > > I tried many things and some shells (bash,csh,tcsh)... > > I think its because the ''. Besides when it seemed do be expressed the > right way I got this answer: > > r.mapcalc 'river=if(river=4032076,4032075,null())' <-debugging output > syntax error, unexpected $end, expecting '=' > Parse error > > or > > syntax error, unexpected '=', expecting ')' > Parse error > > or > > Ungültiger Dateiname. Das Zeichen <=> ist nicht erlaubt. > Ungültige Karte <if(river=4032076,4032075,null())> > Parse error > > depending on what I tried. > > Can someone help? > > Or is there another (and faster) way to query raster-data without > writing a C-Program? > > I'd like to do it inside grass. Otherwise I would export the map to > octave to calculate there, but its not the gentle way I think. > > Thanks, > achim > _______________________________________________ > grass-user mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/grass-user > _______________________________________________ grass-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-user
