[GRASS-user] Why my python script of r.watershed has no output?

Vaclav Petras wenzeslaus at gmail.com
Mon Mar 31 10:46:18 PDT 2014


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, <drainge> 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 at gmail.com> wrote:

> As title, I want to use r.watershed module, and here's my python script in
> pyscripter,
>
> import osimport sys
> #set up GRASS environment variables
> sys.path.append(os.path.join(os.environ['GISBASE'], 'etc', 'python'))import grass.script as gimport 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?<http://gis.stackexchange.com/questions/90784/why-my-python-script-of-r-watershed-has-no-output>,
> thank you.
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20140331/287aa414/attachment-0001.html>


More information about the grass-user mailing list