5

Calling the results of Processing algorithms in order to plot them to the screen differs depending on the provider used.

An example with QGIS provider:

tmpggis = processing.runalg("qgis:reprojectlayer",vektor,"EPSG:4326",None)
out = tmpggis["OUTPUT"]
qgisLyr = QgsRasterLayer(out, "Orfeo")
QgsMapLayerRegistry.instance().addMapLayer(qgisLyr)

So, for QGIS it is: ["OUTPUT"] - capital letters

For GRASS it is: ["output"] - lower case letters

What is the Output name for other providers such as Orfeo Toolbox, SAGA, etc.?

1 Answer 1

7

It may also depend on the algorithm. For example, the Ordinary Kriging from SAGA returns two outputs (VARIANCE and PREDICTION), but other SAGA algorithm outputs are called OUTPUT. So, you cannot just use a single output name for all algorithms in a provider.

However, there is a way to get output parameter names from any Processing algorithm. We can define the following function (for instance in the QGIS Python console):

import processing

def getAlgOutputNames( algName ):
    for output in processing.Processing.getAlgorithm(algName).outputs:
        print output.name

You can call the function in this way, giving it algorithm names you're interested in:

>>> getAlgOutputNames("grass7:v.surf.idw")
output
>>> getAlgOutputNames("qgis:creategrid")
OUTPUT
>>> getAlgOutputNames("saga:ordinarykriging")
PREDICTION
VARIANCE
>>> getAlgOutputNames("gdalogr:clipvectorsbypolygon")
OUTPUT_LAYER
>>> getAlgOutputNames("lidartools:lasmerge")
OUTPUT_LASLAZ
>>> getAlgOutputNames("taudem:dinfinityavalancherunout")
-rz
-dfs
>>>getAlgOutputNames("otb:radiometricindices")
-out

Note: Remember that you can get algorithm names calling processing.alglist() from the QGIS Python console.

5
  • 1
    Great answer, I remember asking a somewhat similar question a while ago: QGIS Python Scripting - Syntax definition.
    – Joseph
    Commented Oct 10, 2016 at 10:04
  • 1
    Thanks for your answer, its really great! The output name for an OTB algorithm I´ve add to the list.
    – N'ya
    Commented Oct 10, 2016 at 18:01
  • Don't really understand why @midavalo rejected your edit. I asked you (N'ya) to let me know the outcome of the command in your environment, and I find much better a direct post edit than another answer or a comment. The edit actually complements the answer and let other people know outcomes for different scenarios. Commented Oct 10, 2016 at 18:15
  • @ German Carrillo: I guess the edit has been accepted now. And I completely agree with your comment, this gathering of direct post edits is better than new answers.
    – N'ya
    Commented Oct 17, 2016 at 15:10
  • @N'ya your edit was rejected, I added your example into the answer. Thanks! Commented Oct 17, 2016 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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