Skip to content
Browse files
[processing] Add an example of running a sub-algorithm correctly
to script template file
  • Loading branch information
nyalldawson committed Apr 27, 2018
1 parent a5a91ec commit 9ce21e4a828a3e9677a9219132711d75fa83dda3
Showing with 18 additions and 0 deletions.
  1. +18 −0 python/plugins/processing/script/
@@ -6,6 +6,7 @@
import processing

class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
@@ -144,6 +145,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

0 comments on commit 9ce21e4

Please sign in to comment.