I know I can create a (QgsFeatureSink
, string) tuple by calling
(sink, dest_id) = self.parameterAsSink(...)
However that requires me to pass an output layer as a parameter:
self.addParameter(
QgsProcessingParameterFeatureSink(
self.OUTPUT,
self.tr('Some output layer'),
QgsProcessing.TypeVectorPolygon
)
)
But in a lot of cases, I really don't want this feature layer as an output. I might use it only for temporary processing. For instance I might generate a number of features and then rasterize them and only present the rasterized result to the user.
How can I create a similar sink from code that only resides in memory during the processing of the algorithm, and is not presented to the user?
QgsProcessingUtils.createFeatureSink()
can help you. Link to docs: qgis.org/api/… And some examples: github.com/qgis/QGIS/search?q=createFeatureSink