Hello again,
just to give you some more information on my problem:
I am running exactly following script:
---------------------------------------------------------------
import sys
import os
import atexit
import grass.script as grass
import grass.script.setup as gsetup
# set mapset/location/dbase/gisbase
gisbase = os.environ['GISBASE'] = "C:/Program Files (x86)/GRASS 6.5"
sys.path.append(os.path.join(os.environ['GISBASE'], "etc", "python"))
gisrc = gsetup.init('C:/Program Files (x86)/GRASS 6.5', 'C:\Users\XY\Documents\Grass GIS', 'Treene_Location', 'Treene')
def cleanup():
pass
def main():
grass.mapcalc("$upstream_shreve = ${upstream_part}+${shreve}",
upstream_shreve = options['upstream_shreve'],
upstream_part = options['upstream_part'],
shreve = options['shreve'])
return 0
if __name__ == "__main__":
options, flags = grass.parser()
atexit.register(cleanup)
sys.exit(main())
-------------------------------------------------------------
and I get following error back from python:
-------------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/Johannes Radinger/Documents/Pyhton Scripts/test3.py", line 40, in <module>
sys.exit(main())
File "C:/Users/Johannes Radinger/Documents/Pyhton Scripts/test3.py", line 32, in main
upstream_shreve = options['upstream_shreve'],
KeyError: 'upstream_shreve'
------------------------------------------------------------
hopefully you can help me why there is an error...
cheers
Johannes
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 AfricaTel: +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@krugs.de
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl