Fwd: Re: [GRASS-user] mapcalc/mapcalculator in python script

Johannes Radinger JRadinger at gmx.at
Wed Feb 2 09:47:08 EST 2011


> 
> On 02/01/2011 03:28 PM, Johannes Radinger wrote:
> > Hello,
> > 
> > I am running GRASS GIS 6.5 and want to run a python script
> > including a mapcaluculator-expression of a simple formula:
> > 
> > A=if(B,C)
> > 
> > grass.mapcalc("$upstream_shreve = if(${upstream_part},${shreve})",
> >                   upstream_shreve = options['upstream_shreve'],
> >                   upstream_part = options['upstream_part'],
> >                   shreve = options['shreve'])
> > 
> > but that isn't working... I don't know whats excaclty the problem....
> 
> I don't know anything about python, but I had a similar problem under R,
> where the problem was escaping of the formula - the formula needed to be
> enclosed in " in grass.
> To diagnose: can you see the command executed under GRASS? Does it work
> if you paste this into GRASS?
> 
> Cheers,
> 
> Rainer


hello,

I still don't know whats the exact problem. And it is not directly possible to paste it into GRASS as the options[] command is processed by
the g.parser module in the end of my script. That's sofar as I understand...

I am not sure if something is wrong with ' and " or with the options-commands. According to the manual (http://grass.osgeo.org/wiki/GRASS_and_Python#Example_for_embedding_r.mapcalc_.28map_algebra.29)
it should work that way...

hopefully someone can help me...

cheers
johannes
> 
> 
> > 
> > hopefully you can help me
> > 
> > thanks
> > Johannes
> 
> 
> - -- 
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
> 
> Centre of Excellence for Invasion Biology
> Natural Sciences Building
> Office Suite 2039
> Stellenbosch University
> Main Campus, Merriman Avenue
> Stellenbosch
> South Africa
> 
> Tel:        +33 - (0)9 53 10 27 44
> Cell:       +27 - (0)8 39 47 90 42
> Fax (SA):   +27 - (0)8 65 16 27 82
> Fax (D) :   +49 - (0)3 21 21 25 22 44
> Fax (FR):   +33 - (0)9 58 10 27 44
> email:      Rainer at krugs.de
>
-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone


More information about the grass-user mailing list