1

I am trying to run r.water.outlet by PyQGIS but getting grass folder not configured error

I have QGIS 2.18 installed and Grass is not installed on windows 10 and I am able to use r.water.outlet from Processing>Toolbox>r.water.outlet but getting error for using it by PyQGIS below code

from qgis.core import * 
from PyQt4.QtGui import *
import processing
registry = QgsMapLayerRegistry.instance()

watershedLayer =registry.mapLayersByName('Gondala_AET-PET')[0]


xmin =  watershedLayer.extent().xMinimum()
xmax = watershedLayer.extent().xMaximum()
ymin = watershedLayer.extent().yMinimum()
ymax = watershedLayer.extent().yMaximum()


processing.runalg('grass:r.water.outlet',  'Drainage direction' , 695991.202933 , 2180877.920948 ,"%f,%f,%f,%f"% (xmin, xmax, ymin, ymax),
    0.0,'b') # 'Drainage direction' is layer name in layer panel

Below is window pop up after running this script.

enter image description here

1

According to , the qgis doc

the path to the GRASS folder has to be defined, but only if you are running Windows. Additionally, a shell interpreter (usually msys.exe, which can be found in most GRASS for Windows distributions) has to be defined and its path set up as well.

To do this, go to the "processing" tab > and "Options" > "Providers" > GRASS etc..enter image description here .

This is a print screen on macOS, so you should set your path correctly according to your windows install.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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