I'm getting some geometries via intersecting lines by polygons (somewhat blindly - I don't really know if intersection exists and actually I don't need to know) using python and QGIS API: some_line.intersection(some_polygon)
.
To my mind I may get several types of geometry:
- None (if there is no intersection).
- Point
- Linestring
- Multilinestring
- Geometry collections (when there are several points and/or lines)
but the geometry I need in the end is a Linestring (Polyline) or several Linestrings (not MultilineStrings). I can identify geometry type using wkbType()
. It returns integer, and this integer corresponds to this order.
How can I split MultilineStrings and Geometry collections and get the parts they are consist of (preferably using QGIS API)?
I wasn't able to find such function in QGIS API, maybe just missed it? There is also GetGeometryRef()
function in OGR that I believe could help me, but I can't figure out how to implement it in my case.