I answered your question at
http://gis.stackexchange.com/questions/90784/why-my-python-script-of-r-watershed-has-no-output/91399#91399
and added an example with full module call:
gcore.run_command('r.watershed', elevation='elev_lid792_1m', drainage='elev_lid_drainage', half='elev_lid_half_basin', accumulation='elev_lid_accumulation', basin='elev_lid_basin', stream='elev_lid_stream', visual='elev_lid_visual', length='elev_lid_length_slope', slope='elev_lid_slope_steepness', threshold=10)
I suppose that the error you are getting is:
Sorry, is not a valid parameter
(followed by a full module help)
Your command in this email has an typo: it should be drainage
not drainge
. As MarkusN pointed out in the other answer at SE.
This command works for me if I change the elevation map to something I have:
gcore.run_command(‘r.watershed’, elevation = ‘hc’, threshold = 5000, accumulation = ‘acc1’, drainage = ‘dra1’, basin = ‘bas1’, stream = ‘str1’, half = ‘hbas1’, visual = ‘vis1’)
Best,
Vaclav
···
On Mon, Mar 31, 2014 at 12:56 PM, Heinz Chen <liebenhans@gmail.com> wrote:
As title, I want to use r.watershed module, and here’s my python script in pyscripter,
import os
import sys
#set up GRASS environment variables
sys.path.append(os.path.join(os.environ['GISBASE'], 'etc', 'python'))
import grass.script as g
import grass.script.setup as gsetup
gisbase = os.environ['GISBASE']
gisdb = 'C:\Users\Heinz\Documents\grassdata'
location = 'newLocation'
mapset = 'TC'
gsetup.init(gisbase, gisdb, location, mapset)
#run r.watershed module
#set thresh = 5000
g.run_command('r.watershed', elevation = 'hc', threshold = 5000, accumulation = 'acc1', drainge = 'dra1', basin = 'bas1', stream = 'str1', half = 'hbas1', visual = 'vis1')
print g.read_command('g.list', _type = 'rast')
the output has generate no new raster data, and if I change the input parameter ‘half’, an error will occur.
Can’t GRASS just take the position of parameters, no matter what their name is, to execute the module?
For more detail, please visit Why my python script of r.watershed has no output?, thank you.
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user