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
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.
-
1Great answer, I remember asking a somewhat similar question a while ago: QGIS Python Scripting - Syntax definition.Joseph– Joseph2016年10月10日 10:04:26 +00:00Commented Oct 10, 2016 at 10:04
-
1Thanks for your answer, its really great! The output name for an OTB algorithm I´ve add to the list.N'ya– N'ya2016年10月10日 18:01:29 +00:00Commented 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.Germán Carrillo– Germán Carrillo2016年10月10日 18:15:47 +00:00Commented 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– N'ya2016年10月17日 15:10:32 +00:00Commented Oct 17, 2016 at 15:10
-
@N'ya your edit was rejected, I added your example into the answer. Thanks!Germán Carrillo– Germán Carrillo2016年10月17日 15:15:27 +00:00Commented Oct 17, 2016 at 15:15
Explore related questions
See similar questions with these tags.