[GRASS-user] Problem with python script in osgeo4w grass 6.4.4 32bit

Helmut Kudrnovsky hellik at web.de
Sun Nov 2 02:59:22 PST 2014


>> why is your script in "../etc/gui/scripts"? as it states this folder is
for
>> GUI scripts; AFAIR this folder may be not in %PATH%.
>This beacause the script have an interface generated by grass parser,

all scripts in C:\OSGeo4W\apps\grass\grass-6.4.x\scripts have an
autogenerated GUI/interface by grass parser.

>I tried your advice, copied the script in
>
>C:\OSGeo4W\apps\grass\grass-6.4.4\scripts
>
>and made the bat file in
>
>C:\OSGeo4W\apps\grass\grass-6.4.x\bin
>
>but tring tu run it i get this error:

tested here on my side:

(1) copied the content of e.g. 
http://trac.osgeo.org/grass/browser/grass-addons/grass6/raster/r.basin/r.basin.py

in r.my.testscript.py and saved the python script in
C:\OSGeo4W\apps\grass\grass-6.4.x\scripts

(2) in C:\OSGeo4W\apps\grass\grass-6.4.x\bin I've added r.my.testscript.bat
with following content

@"%GRASS_PYTHON%" "%GISBASE%/scripts/r.my.testscript.py" %*

=> it works without any problem

> ##
>grass.mapcalc("$mapoutfile =
abs($inraster)",mapoutfile=outraster+'_oname_'+kf.__name__,inraster=outraster+'_'+ofile.__name__)
>##

not tested, but I'm sure that this work.

please have a look in existing python scripts for grass 6 e.g.
http://trac.osgeo.org/grass/browser/grass-addons/grass6/raster/r.basin/r.basin.py
and search how variables in grass.mapcalc are handled there

e.g.
86	def main():
87	    r_elevation = options['map'].split('@')[0] 
[...]
95	    prefix = options['prefix']+'_'+mapname[0]
96	    r_accumulation = prefix+'_accumulation'
[...]
114	    r_mask = prefix+'_mask'
[...]
182	        grass.mapcalc("tmp = $r_accumulation / $r_mask",
183	                       r_accumulation = r_accumulation,
184	                       r_mask = r_mask)



-----
best regards
Helmut
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Problem-with-python-script-in-osgeo4w-grass-6-4-4-32bit-tp5170744p5170806.html
Sent from the Grass - Users mailing list archive at Nabble.com.


More information about the grass-user mailing list