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.?
Answer
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.
No comments:
Post a Comment