Dear all, This is kind of my first e-mail ever to ANY mailing list, so please forgive me if I don't express myself in the best way. I will improve eventually. I am a total beginner in python and GRASS (and any other programming language), so I am trying to run the first examples found in http://grass.osgeo.org/wiki/GRASS_and_Python. I managed to run the shaded_relief one OK, but the one with respect to mapcalc, I couldn't. I copied a script found in http://www.mail-archive.com/grass-...@lists.osgeo.org/msg14669.html (transcribed below) and tried to run it:
#!/usr/bin/env python # g.parser demo script for python programing #%module #% description: g.parser test script (python) TUN #%end #%flag #% key: f #% description: A flag #%end #%flag #% key: n #% description: Another flag #%end #%option #% key: raster1 #% type: string #% gisprompt: old,cell,raster #% description: Raster input map #% required : yes #%end #%option #% key: raster2 #% type: string #% gisprompt: old,cell,raster #% description: Raster2 input map #% required : yes #%end #%option #% key: output #% type: string #% gisprompt: new,cell,raster #% description: Output #% required : yes #%end import os import sys import grass.script as grass def main(): output = options['output'] raster1 = options['raster1'] raster2 = options['raster2'] grass.mapcalc("$out = $rast1 + $rast2", out = output, rast1 = raster1, rast2 = raster2) if flags['f']: print "Flag -f set" else: print "Flag -f not set" if flags['n']: print "Flag -n foi definida mas nao devia" else: print "Flag -n not set- GOOD" print options print flags return 0 if __name__ == "__main__": options, flags = grass.parser() sys.exit(main()) It seems to run OK and “100%” is displayed in the GRASS prompt, but when I tried to display the map, I found out that it wasn't created at all. Just for you to know, to run the script I simply create it (say “myscript.py”), give permissions and run it in a GRASS session with the necessary options: > ./myscript.py output=outmap raster1=map1 raster2=map2 I am using Ubuntu 9.04 64bits and GRASS 6.4.ORC5. Can anyone help me? Best regards, Marcello Gorini. -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Trying-python-scripts-tp5109105p5109105.html Sent from the Grass - Users mailing list archive at Nabble.com. _______________________________________________ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user