I would like to extract flow accumulation and flow direction layers from a DEM calling the grass r.watershed module from a QGIS-python script using the processing class. I obtain just an empty map, while, using the processing GUI I get the map I was expecting. Here is my code:
from PyQt4.QtCore import * import processing # "mydem" is the loaded dem layer dem=QgsMapLayerRegistry.instance().mapLayersByName("mydem") processing.runalg("grass:r.watershed", dem, None, None, None, None, 10, None, None, 300, None, 1, None, None, None, 40, "C:\\Users\\flc\\Desktop\\QGIS_Plugins\\layers\\acc.tif", "C:\\Users\\flc\\Desktop\\QGIS_Plugins\\layers\\dir.tif", None, None, None, None, None, None)
The 6th argument is the threshold. It is not needed for the computation of flow accumulation and flow direction, but in my trials with the GUI (the processing GUI, not the GRASS GUI) I found that the algorithm works when it is specified. However, I tried a lot of combinations of parameters. Do you have any idea about how could it work?