[GRASS-dev] r.mapcal and python
Massimiliano Cannata
massimiliano.cannata at supsi.ch
Mon Nov 10 10:05:50 EST 2008
Ciao Roberto,
try with this solution:
output='yourmap'
map1='yourmap1'
map2='yourmap2'
cmdargs2=["%s=if(%s>%s,10000,0)"%(output,map1,map2)]
os.spawnvp(os.P_WAIT,"r.mapcalc", ["r.mapcalc"] + cmdargs2)
It works for me ;-)
Massimiliano
Roberto Antolín wrote:
> Hi all,
> I'm a python newbie so have some patience :-)
>
> I'm trying to use r.mapcal with the grass.py function 'run_command' in
> this way:
>
> e = "%s=%s-%s" % (out, dsm, dtm)
> grass.run_command('r.mapcalc', expression = e)
>
> However, the new raster in "%out" doesn't appear, and a new raster
> called 'expression' is created instead.
>
> I also tried with:
>
> grass.run_command('r.mapcalc', expression = "%s=%s-%s" % (out, dsm, dtm))
>
> with the same result. And also with:
>
> grass.run_command('r.mapcalc', %s = "%s-%s" % (out, dsm, dtm))
>
> which threw at me an execution error.
>
> Any suggestion?
>
> Thanks in advanced,
> Roberto.
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
--
-----------------------------------------------------
Dr. Massimiliano Cannata
Environmental & Geomatic Engineer
Institute of Earth Sciences - SUPSI
Trevano, C.P. 72, CH-6952 Canobbio, SWITZERLAND
Tel: +41 (0)58 / 666 62 14
Fax: +41 (0)58 / 666 62 09
E-mail: massimiliano.cannata at supsi.ch
Web:
http://www.ist.supsi.ch
http://istgis.ist.supsi.ch:8001/geomatica/
-------------------------------------------------------
More information about the grass-dev
mailing list