I'm new at this. I am "building" a python plugin for qgis and I want to import modules from GRASS and SAGA but I don't understand how to do it. The plugin I want to import is Kriging interpolation from SAGA or v.surf.idw from GRASS or interpolation plugin from Raster qgis. I want an interpolation method to convert points in grid.

Can you help me?

I have another doubt.

I run these lines in my code:

vectorlayer_vector =  ftools_utils.getVectorLayerByName(inputLayer)
Elevation = self.lineAttrib.currentText()
cellSize = int(self.linePix.value())
outPath = self.inputLayerCombo3.text()
output = ftools_utils.getRasterLayerByName(outPath) 

Processing.runAlgorithm("saga:shapestogrid", vectorlayer_vector, Elevation, 0, 0, 4, None, cellSize, output)

When I run, I get an tiff image but with nothing. The .aux file is not created and when I try to open the tiff image that I created appears this message:

c:...teste3.tif is not a supported raster data source

So, I guess that the output is wrong. What I have to do to get a correct output? What I missing?


The Processing framework in QGIS can call these function directly from Python.

From the QGIS Python console:

>>>import processing
>>>outputs_0=Processing.runalg("saga:ordinarykriging", vectorlayer_pointtable, z, True, 0, 0, True, 100, True, 0.0, 10.0, 100.0, 1.0, 0.1, 1, 0.5, 1000.0, 4, 20, 1.0, True, None, None, None)
>>>outputs_1=Processing.runalg("grass:r.surf.idw", outputs_0['GRID'], 12, True, None, 0.0, None)

If you build it as a model in the Processing Framework, you can save that model as a Python script. It gives you a kind of GUI builder for the processing runalg function.

Processing model

enter image description here

  • Your answer was very helpfull. Thanks. So, if I create a Python script from sextante model, I can incorporate that code in my plugin? – Bárbara Duarte Nov 14 '13 at 13:44
  • Yes, code runs in a plugin too. – Jakob Nov 14 '13 at 21:25
  • When I run the code, it gaves me this message "AttributeError: class Processing has no attribute 'runalg'". Why? I import processing. – Bárbara Duarte Nov 15 '13 at 15:02
  • I know the answer to my question. In my QGIS version I have the function runAlgorithm instead of runalg. Now this works fine. Thank you. – Bárbara Duarte Nov 15 '13 at 15:24

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.