I would like to save a selection of a polygon vector layer to a newly created line vector layer. Manually, this can be done by: Right-Click on vector layer > Save As > Geometry Type > Line String.
How would I get the same result with PyQGIS?
Until now this works, but creates a polygon vector layer (same as input):
QgsVectorFileWriter.writeAsVectorFormat(vlayer, lines, "utf-8", None, "ESRI Shapefile", 1)
From https://qgis.org/api/classQgsVectorFileWriter.html, I don't understand how or if it is possible to overwrite the output WKB type to MultiLineString. I tried several versions of:
QgsVectorFileWriter.writeAsVectorFormat(vlayer, lines, "utf-8", None, "ESRI Shapefile", 1, Qgis.WKBMultiLineString)
Does anyone know how to do this?