I have a problem. I am developing a standalone app in python and I need to use processing algorithms. I was able to use one algorithm without erros but I need to run other processing algorithm which input is the output of the first one. So, my program stops in the first algorithm. Why it doesn't read the second one?
import sys from qgis.core import QgsApplication, QgsVectorLayer from PyQt4.QtGui import QApplication from PyQt4.QtCore import QFileInfo import GdalTools_utils import ftools_utils import osgeo import ogr import gdal app = QApplication() QgsApplication.setPrefixPath("/usr", True) QgsApplication.initQgis() from processing.core.Processing import Processing Processing.initialize() inputLayer = QgsVectorLayer(...) inputMask = QgsVectorLayer(...) extent_rect = inputMask.extent() xmin = extent_rect.xMinimum() xmax = extent_rect.xMaximum() ymin = extent_rect.yMinimum() ymax = extent_rect.yMaximum() extent = str(xmin) + "," + str(xmax) + "," + str(ymin) + "," + str(ymax) cellsize = 30 outrains10 = '...' count = inputLayer.featureCount() rain_10 = 'rains10' days_10 = 'days10' Processing.runAlgorithm("grass:v.surf.idw", None, inputLayer, count, 2.0,rain_10, False,extent, cellsize, -1.0, 0.0001, outrains10) Processing.runAlgorithm("saga:clipgridwithpolygon", None, outrains10 , inputMask, outclip_rains10)
So the first algorithm grass is OK. The output is fine. But I want to use it as input in the second one, but the code stops there.
The code stops because I didn't know that I have to install SAGA to use in linux. Now I have SAGA installed (I run from QGIS and everything is ok) but I still don't know how to configure saga to read through processing, such as the line:
Processing.runAlgorithm("saga:clipgridwithpolygon", None, outrains10 , inputMask, outclip_rains10)
I still doesn't get saga working but with many many tries, I found that, when I run the script, an error (Segmentation fault) and others are returned. So debugging my code I found that is the input raster which gives the error:
grid = QgsRasterLayer('/.../raster.tif')
Does anyone knows why this is happen?? Can you help me please?