My first processing runalg creates a memory layer as output. I need to use this layer as the input for the second runalg.

processing.run("qgis:fieldcalculator", {'INPUT':'test_1_f08f5cd1_13ea_445b_9778_6ee0ab919030','FIELD_NAME':'1.3-field','FIELD_TYPE':0,'FIELD_LENGTH':10,'FIELD_PRECISION':3,'NEW_FIELD':True,'FORMULA':'((length(shortest_line(centroid($geometry),boundary($geometry)))))*1.3','OUTPUT':'memory:'})

processing.run("qgis:fieldcalculator", {'INPUT':?????,'FIELD_NAME':'1.3-field','FIELD_TYPE':0,'FIELD_LENGTH':10,'FIELD_PRECISION':3,'NEW_FIELD':True,'FORMULA':'((length(shortest_line(centroid($geometry),boundary($geometry)))))*1.3','OUTPUT':'memory:'})

I have found this links but none could help me.


1 Answer 1


I have chained processing algorithms within a processing script by adding the output of the first algorithm to a sink (see underdark's tutorial) then using dest_id1 (for example) as the input for the next processing script. I found that it was necessary to add the line del sink between uses of the sink and to declare OUTPUT1 = "OUTPUT_1" and OUTPUT2 = "OUTPUT_2" at the start of the script and the syntax at the end that worked for me was:

results = {}
results[self.OUTPUT1] = dest_id1
results[self.OUTPUT2] = dest_id2
return results

All other syntax to do with outputs has to be duplicated. Good luck:)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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