[GRASS-dev] Python Scripts- mapcalc
António Rocha
antonio.rocha at deimos.com.pt
Fri Feb 12 08:18:26 EST 2010
YOu right
Here it goes
Thank you
Glynn Clements wrote:
> António Rocha wrote:
>
>
>> options, flags = grass
>>
>
> I presume that the rest got lost here?
>
>
>> When I enter:
>> python.teste raster1=aspect at PERMANENT raster2=aspect at PERMANENT
>> output=Zteste8
>>
>> GRASS freezes, I mean. It's still processing without stopping or exiting
>> or even any error. Any idea of what might be wrong?
>>
>
> No. If you post the complete script as an attachment, I can test it.
>
>
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4860 (20100212) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
-------------- next part --------------
#!/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())
__________ Information from ESET NOD32 Antivirus, version of virus signature database 4860 (20100212) __________
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
More information about the grass-dev
mailing list