Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from PyQt5.QtCore import QCoreApplication
- from qgis.core import (QgsProcessing,
- QgsFeatureSink,
- QgsProcessingException,
- QgsProcessingAlgorithm,
- QgsProcessingParameterFeatureSource,
- QgsProcessingParameterFolderDestination)
- import processing
- class ExampleProcessingAlgorithm(QgsProcessingAlgorithm):
- INPUT = 'INPUT'
- OUTPUT = 'OUTPUT'
- def tr(self, string):
- return QCoreApplication.translate('Processing', string)
- def createInstance(self):
- return ExampleProcessingAlgorithm()
- def name(self):
- return 'myscript'
- def displayName(self):
- return self.tr('My Script')
- def group(self):
- return self.tr('Example scripts')
- def groupId(self):
- return 'examplescripts'
- def initAlgorithm(self, config=None):
- self.addParameter(
- QgsProcessingParameterFeatureSource(
- self.INPUT,
- self.tr('Input layer'),
- [QgsProcessing.TypeVectorAnyGeometry]
- )
- )
- self.addParameter(
- QgsProcessingParameterFolderDestination(
- self.OUTPUT,
- self.tr('Output layer')
- )
- )
- def processAlgorithm(self, parameters, context, feedback):
- source = self.parameterAsSource(
- parameters,
- self.INPUT,
- context
- )
- output = self.parameterAsString(
- parameters,
- self.OUTPUT,
- context
- )
- feedback.pushDebugInfo(output)
- return {self.OUTPUT: output}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement