[GRASS-user] script in python
Gabriele Nolè
gis.gn at libero.it
Sun Nov 30 10:48:50 EST 2008
Hi.
I'm trying to write a little script in python but I have difficulty (I know
a bit the bash).
The script must first run a buffer and then some overlay.
I am following the wiki and seeing some script as v.type.py, color_table.py
etc. ..
Now I am at this point:
#!/usr/bin/env python
############################################################################
import sys
import os
import grass
import commands
#%module
#% description: rischio
#%end
#%option
#% key: vect_1
#% type: string
#% required: yes
#% multiple: no
#% key_desc: name
#% description: Name of input vector map (centro urbano)
#% gisprompt: old,vector,vector
#%end
#
#%option
#% key: vect_2
#% type: string
#% required: yes
#% multiple: no
#% key_desc: name
#% description: Name of input vector map (uso del suolo)
#% gisprompt: old,vector,vector
#%end
#
#%option
#% key: vect_3
#% type: string
#% required: yes
#% multiple: no
#% key_desc: name
#% description: Name of input vector map (pendenza-classi)
#% gisprompt: old,vector,vector
#%end
def main():
#add your code here
print ""
print "Value of GIS_OPT_vect_1: %s" % os.getenv("GIS_OPT_vect_1")
print "Value of GIS_OPT_vect_2: %s" % os.getenv("GIS_OPT_vect_2")
print "Value of GIS_OPT_vect_3: %s" % os.getenv("GIS_OPT_vect_3")
grass.run_command('v.buffer', input = vect_1 output = buffer_200m buffer
= 200)
# or grass.exec_command ?
#end of your code
if __name__ == "__main__":
args = ""
for arg in sys.argv:
args += arg+" "
try:
if ( sys.argv[1] != "@ARGS_PARSED@" ):
os.system("g.parser %s " % (args))
except IndexError:
os.system("g.parser %s" % (args))
if sys.argv[1] == "@ARGS_PARSED@":
main();
Thanks
Gabriele
--
View this message in context: http://www.nabble.com/script-in-python-tp20758838p20758838.html
Sent from the Grass - Users mailing list archive at Nabble.com.
More information about the grass-user
mailing list