Another option is the GRASS's v.to.lines
(search in the Processing Toolbox Ctrl+Alt+T).
For PyQGIS it is grass7:v.to.lines
>>> processing.algorithmHelp("grass7:v.to.lines")
v.to.lines (grass7:v.to.lines)
Converts vector polygons or points to lines.
----------------
Input parameters
----------------
input: Name of input vector map
Parameter type: QgsProcessingParameterFeatureSource
Accepted data types:
- str: layer ID
- str: layer name
- str: layer source
- QgsProcessingFeatureSourceDefinition
- QgsProperty
- QgsVectorLayer
method: Method used for point interpolation
Parameter type: QgsProcessingParameterEnum
Available values:
- 0: delaunay
Accepted data types:
- int
- str: as string representation of int, e.g. '1'
- QgsProperty
output: Lines
Parameter type: QgsProcessingParameterVectorDestination
Accepted data types:
- str
- QgsProperty
- QgsProcessingOutputLayerDefinition
GRASS_REGION_PARAMETER: GRASS GIS 7 region extent
Parameter type: QgsProcessingParameterExtent
Accepted data types:
- str: as comma delimited list of x min, x max, y min, y max. E.g. '4,10,101,105'
- str: layer ID. Extent of layer is used.
- str: layer name. Extent of layer is used.
- str: layer source. Extent of layer is used.
- QgsMapLayer: Extent of layer is used
- QgsProcessingFeatureSourceDefinition: Extent of source is used
- QgsProperty
- QgsRectangle
- QgsReferencedRectangle
- QgsGeometry: bounding box of geometry is used
GRASS_SNAP_TOLERANCE_PARAMETER: v.in.ogr snap tolerance (-1 = no snap)
Parameter type: QgsProcessingParameterNumber
Accepted data types:
- int
- float
- QgsProperty
GRASS_MIN_AREA_PARAMETER: v.in.ogr min area
Parameter type: QgsProcessingParameterNumber
Accepted data types:
- int
- float
- QgsProperty
GRASS_OUTPUT_TYPE_PARAMETER: v.out.ogr output type
Parameter type: QgsProcessingParameterEnum
Available values:
- 0: auto
- 1: point
- 2: line
- 3: area
Accepted data types:
- int
- str: as string representation of int, e.g. '1'
- QgsProperty
GRASS_VECTOR_DSCO: v.out.ogr output data source options (dsco)
Parameter type: QgsProcessingParameterString
Accepted data types:
- str
- QgsProperty
GRASS_VECTOR_LCO: v.out.ogr output layer options (lco)
Parameter type: QgsProcessingParameterString
Accepted data types:
- str
- QgsProperty
GRASS_VECTOR_EXPORT_NOCAT: Also export features without category (not labeled). Otherwise only features with category are exported
Parameter type: QgsProcessingParameterBoolean
Accepted data types:
- bool
- int
- str
- QgsProperty
----------------
Outputs
----------------
output: <QgsProcessingOutputVectorLayer>
Lines