Skip to content


[processing] Add an example of running a sub-algorithm correctly
Browse files Browse the repository at this point in the history
to script template file

(cherry-picked from 9ce21e4)
  • Loading branch information
nyalldawson committed May 3, 2018
1 parent 1e82e07 commit b28b588
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions python/plugins/processing/script/
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import processing

class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
Expand Down Expand Up @@ -136,6 +137,23 @@ def processAlgorithm(self, parameters, context, feedback):
# Update the progress bar
feedback.setProgress(int(current * total))

# To run another Processing algorithm as part of this algorithm, you can use
# Make sure you pass the current context and feedback
# to to ensure that all temporary layer outputs are available
# to the executed algorithm, and that the executed algorithm can send feedback
# reports to the user (and correctly handle cancelation and progress reports!)
if False:
buffered_layer ="native:buffer", param={
'INPUT': dest_id,
'DISTANCE': 1.5,
'DISSOLVE': False,
'OUTPUT': 'memory:'
}, context=context, feedback=feedback)['OUTPUT']

# Return the results of the algorithm. In this case our only result is
# the feature sink which contains the processed features, but some
# algorithms may return multiple feature sinks, calculated numeric
Expand Down

0 comments on commit b28b588

Please sign in to comment.