2

I'm using the SAGA Upslope Area algorithm within pyqgis, but i'm stranded, since my script doesn't create any output at all. I'm trying to use geometry from points in a vector point layer as input x and y in the saga algorithm, but it doesn't give me any error messages and i can't seem to find the problem. Can you see any problem with my script below?

##points=vector
##dtm=raster
##upslope_area=output raster

from qgis.core import *
from PyQt4.QtCore import *
from processing import *

upslope_area = processing.getObject(upslope_area)
iterator_points = processing.getObject(points)
dtm = processing.getObject(dtm)

for feature in iterator_points.getFeatures():
    geometry = feature.geometry()
    point = geometry.asPoint()
    x_point = point[0]
    y_point = point[1]
    Processing.initialize()
    processing.runalg('saga:upslopearea', None,x_point,y_point,dtm,None,0,1.1,upslope_area)  
  • Doesn't Upslope Area need a Grid instead of a Point file? I recommend getting the Tool working in the Desktop app, then working on the script. – klewis Oct 10 '16 at 13:57
2
+50

I don't have data to test with but made some dummy files and simplfied your code a little which runs and outputs temporary files. Couldn't confirm if the results were correct but it was just a test to see if any output files are generated:

##points=vector
##dtm=raster

iterator_points = processing.getObject(points)

for feature in iterator_points.getFeatures():
    geometry = feature.geometry()
    point = geometry.asPoint()
    x_point = point[0]
    y_point = point[1]
    processing.runandload('saga:upslopearea',None,x_point,y_point,dtm,None,0,1.1,None)

it should be like:

processing.runandload('saga:upslopearea',None,x_point,y_point,dtm,None,0,1,1,None)

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.