I created a processing script in QGIS 2.18 that connects two processing algorithms (first clip and than dissolve). The output vector from the clip is supposed to be an input into the dissolve.
The code of my processing script is provided here:
##input_layer=vector
##clip_layer=vector
##clipped_layer=output vector
##processed_layer=output vector
clip_area = processing.runalg("qgis:clip", input_layer, clip_layer,
clipped_layer)
fin_area = processing.runalg("qgis:dissolve", clip_area, "true", None,
processed_layer)
The screeshot of processing script UI when I try to run it is below:
Both of the algorithms work correctly standalone, but when I try to pipe them it does not work as intended. I only get clipped_layer as output and the following error notification in Python Console:
There are several questions adressing related issues like Pipe custom processing algorithm output into another in QGIS 3.0 but none really answers my question.
Does anybody know how to correctly pipe algorithms in the example processing script provided above?
I know it could be solved by using Processing Modeler but since I plan to expand the script further, please, don´t suggest this as solution.
Answer
The processing.runalg() return a python dictionary with one record: 'OUTPUT' is the key and the value is the absolute path at result layer.
So in the next algorithm instead of the parameter clip_area
you have to use clip_area['OUTPUT']
No comments:
Post a Comment