[GRASS-user] Running a Pyhton Script on Mac (Mapcalc)

Johannes Radinger JRadinger at gmx.at
Tue Mar 22 06:02:54 EDT 2011


Hello,

I'd like to run a python script on my GRASS6.5 on MacOS.

I saved a *.py script for testing with following content on my desktop:

#!/usr/bin/python
#
#%Module
#% description: mapcalc test
#%End
#%option
#% key: upstream_shreve
#% type: string
#% gisprompt: new,cell,raster
#% description: output
#% required: yes
#%ends
#%option
#% key: upstream_part
#% type: string
#% gisprompt: old,cell,raster
#% description: input 1
#% required: yes
#%option
#% key: shreve
#% type: string
#% gisprompt: old,cell,raster
#% description: input 2
#% required: yes
#%end


import sys
import os
import atexit

import grass.script as grass
import grass.script.setup as gsetup

def cleanup():
    pass

def main():
    grass.mapcalc("$upstream_shreve = if(${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())


All the needed files (upstream_part, shreve) are existing in the location and mapset that is open. Then I tried to execute File-->Launch Script and choose it. Then I just get back: 

Launching script '/Users/Johannes Radinger/Desktop/mapcalc-test.py'...          
(Tue Mar 22 10:57:15 2011)                                                      
/Users/Johannes Radinger/Desktop/mapcalc-test.py                                
(Tue Mar 22 10:57:15 2011) Command finished (0 sec)

and nothing happend and no map was created...

what is wrong with my script?

/johannes

-- 
NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
Jetzt informieren: http://www.gmx.net/de/go/freephone


More information about the grass-user mailing list