4

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:

UI of processing script

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:

enter image description here

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Apr 20, 2018 at 15:07
1
  • 2
    Try using fin_area = processing.runalg("qgis:dissolve", clip_area['OUTPUT'], "true", None, processed_layer) Commented Apr 20, 2018 at 15:12

1 Answer 1

3

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']

answered Apr 21, 2018 at 10:48
2
  • Yes, you need to specify the 'OUTPUT' with the output layer. This worked for me. Thanks Does this work for all kind of algorithms with spatial outputs? Commented Apr 23, 2018 at 7:48
  • 1
    Sometimes changes the key string value 'OUTPUT', you have to print the dictionary result to know it... Take care that all of this is heavily changed in QGIS 3.0 Commented Apr 23, 2018 at 8:26

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.