My algorithm needs a temporary layer in a QGIS processing script. I can use regular pyqgis api to create a temporary layer but want to know if there is a preferred and processing-specific way of doing it. Since processing already creates a temporary directory for the output, can it be used for creating another layer? Can I use processing.core.Vectorwriter or some other helper method?
Edit:
I use the following right-now and looking for something more processing-specific and preferably writing to processing temporary dir instead of a memory layer.
templayer = QgsVectorLayer('Polygon?crs=%s' % input_layer.crs().authid(), 'temp', 'memory')
dataProvider = templayer.dataProvider()
templayer.startEditing()
dataProvider.addFeatures([features])
templayer.commitChanges()
templayer.updateExtents()
Best Answer
I've probably misunderstood you but using
None
in a processing script creates a temporary output file which can also be used as an intermediate layer in scripts. From the docs:The temporary files are stored in a processing temporary directory. For my Windows 7 system, this is: