I am writing a Processing
python script based on the template provided here.
I am creating lines (destined to the 'OUTPUT') and I would like to clip them according to a polygon entered as the 'INPUT' parameter). I can't figure out how to call the Algorithm. For what it's worth, this doesn't work:QgsProcessingAlgorithm('qgis:clip').run({'INPUT': self.OUTPUT, 'OVERLAY': self.INPUT})
I have tried several ways but couldn't get far as I get the error: qgis._core.QgsProcessingAlgorithm represents a C++ abstract class and cannot be instantiated
Answer
I have found the following to work:
temp = QgsVectorLayer('Line', 'temp', 'memory')
# do some stuff with temp
clipped_lines = processing.run('native:clip', {
'INPUT': temp,
'OVERLAY': parameters['INPUT'],
'OUTPUT': 'memory:ClippedLines',
}, context=context, feedback=feedback)['OUTPUT']
No comments:
Post a Comment