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

Helena Mitasova hmitaso at ncsu.edu
Thu Feb 14 08:41:24 PST 2013



> 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())

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



More information about the grass-dev mailing list