I am working under Qgis 2.16.0 and i am trying to make a script using the grass module r.water.oulet. This module has 5 parameters :

1 - Name of input raster 2 - coordinates of outlet point (x,y) 3 - area of the Grass region (xmin, xmax, ymin, ymax) 4 - Celle size of Grass Region 5- Output file

When i use the module in Qgis I don't need to set the area of Grass region. But if d'ont set it in python command :

processing.runalg('grass:r.water.outlet', "D:\Developpement\Debits_cartes_alea\Donnees_test\flow_direction.tif",936400.018,6432568.853,None,0.0,"D:\Developpement\Debits_cartes_alea\Donnees_test\1sortie.tif")

I have this error message : "Error: Wrong parameter value: None"

So I try to set the required coordinates like this :

processing.runalg('grass:r.water.outlet', "D:\Developpement\Debits_cartes_alea\Donnees_test\flow_direction.tif",936400.018,6432568.853,['933963.950608,940746.141038,6431270.66542,6434790.6058'],0.0,"D:\Developpement\Debits_cartes_alea\Donnees_test\1sortie.tif")

Then I have this error message : "Error: Wrong parameter value: ['933963.950608,940746.141038,6431270.66542,6434790.6058']"

Does that come from the syntax or is ther the problem with the values (note that I try with the same values in module and it's work !)

  • did you try without the brackets []? And for None with 'None' ?
    – Victor
    Sep 16, 2016 at 15:55
  • Yes I try both. If I don't use bracket [] then the error is that I don't give the good number of parameters. If I try 'None' the problem is the same than with None.
    – Panvjim0
    Sep 16, 2016 at 16:02
  • I am guessing sorry, but shouldn't you have '936400.018,6432568.853' for third parameter?
    – Victor
    Sep 16, 2016 at 16:06
  • I think there is no problem with the parameters values because when I try with the same values using the module it works well.
    – Panvjim0
    Sep 19, 2016 at 6:22

1 Answer 1


Usually when I run processes, I define the extent instead of leaving it blank (which often results in errors like you have shown). So you could use something like the following:

# Define input and output paths
path = "D:/Developpement/Debits_cartes_alea/Donnees_test/flow_direction.tif"
output = "D:/Developpement/Debits_cartes_alea/Donnees_test/1sortie.tif"

# Get raster data
fileInfo = QFileInfo(path)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(fileName, baseName)

# Define the minimum extent of the region
extent = rlayer.extent()
xmin = extent.xMinimum()
xmax = extent.xMaximum()
ymin = extent.yMinimum()
ymax = extent.yMaximum()

import processing
processing.runalg('grass:r.water.outlet', path,
    "%f,%f,%f,%f"% (xmin, xmax, ymin, ymax),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.