[GRASS-dev] formatting expressions for r.mapcalc in GRASS6.4.3

Anna Kratochvílová kratochanna at gmail.com
Thu Feb 14 09:25:18 PST 2013


On Thu, Feb 14, 2013 at 5:41 PM, Helena Mitasova <hmitaso at ncsu.edu> wrote:
>
>
>> The wxGUI command line has its own rules (see shlex.split()
>> in the Python library documentation).
>
> running mapcalc through the wxGUI command line is where the students have problems in winGRASS
> (but it works on Mac)
>
> Helmut - can you please try this commands with data in nc_spm_08
> just pasting them in command console in wingrass?
> - I had them originally in double quotes but that did not work for any expression,
> without quotes this works:
>
> g.region rast=landuse96_28m -p
> r.mapcalc ndvi3=float(lsat7_2002_40-lsat7_2002_30)/float(lsat7_2002_40+lsat7_2002_30)
>
> but the students complain that the ones with if statements don't
> (they say that they tried to put spaces around = and some other modifications but they keep getting syntax error):
>
> r.mapcalc urban1_30m=if(landuse96_28m==1,1,0)+if(landuse96_28m==2,2,0)
> r.mapcalc urban2_30m=if(landuse96_28m==1 || landuse96_28m==2,landuse96_28m,null()
> g.region rast=elevation -p
> r.mapcalc MASK=if((elevation<100 && elevation>60) && (landuse96_28m==1 || landuse96_28m==2),1,null())

One problem is caused by the pipe character. It seems that it is taken
as the end of a command and the rest is evaluated as another command.
I noticed the same problem when I wanted to execute a command
(run_command) with option separator = "|" from gui. It's a general
problem both in grass 6 and 7.

Anna

>
> so I am trying to figure out how to make r.mapcalc work in wingrass in command console
> (all of these expressions work if entered through the map calculator GUI)
>
> r.mapcalc is one of the most used commands so I think it is important to have it running reliably
> and it may be just a matter of special instrcutions for wingrass in the manual page,
>
> Thank you, Helena
>
>>
>> Map names can be quoted with either single or double quotes, so if the
>> expression is quoted with double quotes you can quote map names with
>> single quotes and vice-versa.
>>
>> --
>> Glynn Clements <glynn at gclements.plus.com>
>> _______________________________________________
>> grass-dev mailing list
>> grass-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev


More information about the grass-dev mailing list