Re: [GRASS-user] scripting mapcalc

2009-03-06 Thread Daniel Victoria
Hi Glynn, That is good to know. I started using that form because I would always get confused with ' and so I though that using the echo command would be safer. But now that I know better, my scripts will be simpler Daniel On Fri, Mar 6, 2009 at 1:41 AM, Glynn Clements gl...@gclements.plus.com

Re: [GRASS-user] scripting mapcalc

2009-03-06 Thread Nikos Alexandris
Nikos: Try this: r.mapcalc river=if(river==$old, $new, null()) Glynn: Note that this won't work in 7.0, where r.mapcalc uses the parser. It will complain that r.mapcalc doesn't have a river=... option. For portability, always: 1. quote the entire expression, and 2. insert a space

Re: [GRASS-user] scripting mapcalc

2009-03-06 Thread Glynn Clements
Nikos Alexandris wrote: Nikos: Try this: r.mapcalc river=if(river==$old, $new, null()) Glynn: Note that this won't work in 7.0, where r.mapcalc uses the parser. It will complain that r.mapcalc doesn't have a river=... option. For portability, always: 1. quote the entire

RE: [GRASS-user] scripting mapcalc

2009-03-06 Thread Patton, Eric
In general, it's preferable to do as much as possible in each r.mapcalc command. E.g. rather than: r.mapcalc $GIS_OPT_OUTPUT.r = r#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT + (1.0 - .$GIS_OPT_PERCENT) * r#$GIS_OPT_SECOND r.mapcalc $GIS_OPT_OUTPUT.g = g#$GIS_OPT_FIRST * .$GIS_OPT_PERCENT

[GRASS-user] scripting mapcalc

2009-03-05 Thread achim
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.

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread Nikos Alexandris
Try this: r.mapcalc river=if(river==$old, $new, null()) Cheers, Nikos ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread achim
Its awful! That does work (in tsch so far! I tried -not alone- for hours... Thank you very much, Nikos! Maybe you know a way to make r.mapcalc quiet? Or maybe to query a rastermap col-row wise? Greetings from Potsdam at the moment. achim Nikos Alexandris schrieb: Try this: r.mapcalc

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread Nikos Alexandris
Hallo Achim! On Thu, 2009-03-05 at 15:55 +0100, achim wrote: Its awful! That does work (in tsch so far! What is _tsch_? Do you mean _tcsh_? Sorry for my ignorance if it's something I _should_ know :-) Maybe you know a way to make r.mapcalc quiet? Not really. The Experts should know that

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread achim
The Problem isn't solved yet!! I posted an easy example, but calculating with more complicated scenarios I got these: r.mapcalc river=if(river[0,1]=4032076 ,4032075,river) syntax error, unexpected '=', expecting ')' Parse error or r.mapcalc river=if( river=4032076 ||| river=4032076

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread Markus Neteler
On Thu, Mar 5, 2009 at 3:42 PM, achim a...@jupiter.uni-freiburg.de 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

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread Glynn Clements
Nikos Alexandris wrote: Try this: r.mapcalc river=if(river==$old, $new, null()) Note that this won't work in 7.0, where r.mapcalc uses the parser. It will complain that r.mapcalc doesn't have a river=... option. For portability, always: 1. quote the entire expression, and 2. insert a space

Re: [GRASS-user] scripting mapcalc

2009-03-05 Thread Glynn Clements
Daniel Victoria wrote: 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