[GRASS-dev] r.mapcal and python

Massimiliano Cannata massimiliano.cannata at supsi.ch
Tue Nov 11 07:57:24 EST 2008


Glynn Clements wrote:
> Roberto Antolí­n wrote:
>
>   
>>> 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)
>>>       
>> Thank you, Maxi! It works perfectly well. I think I'll use this solution 
>> rather than the grass.py library for 'r.mapcalc'.
>>     
>
> Don't use the os.spawn* functions; they have been superseded by
> subprocess.Popen() and subprocess.call().
>
>   
Yes, replace spawn* with popen or call. It is the right direction.

P.s.: Only call can handle the P_WAIT mode?

Maxi

-- 
-----------------------------------------------------
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