Skip to main content
7 votes

Getting coordinates of Line or MultiLine using PyQGIS

For single part LineString: layer = QgsProject.instance().mapLayersByName("Single parts")[0] for feature in layer.getFeatures(): for pnt in feature.geometry().asPolyline(): ...
Zoltan's user avatar
  • 7,450
6 votes
Accepted

Does the $length function support LineStringZ in QGIS Field Calculator?

For QGIS versions QGIS 3.20 and greater Now one can calculate the 3D length of a MultiLineStringZ with the length3D($geometry) function, see the Changelog for QGIS 3.20 for more details.
Rob Irwin's user avatar
  • 336
5 votes

Geting midpoint of MultiLine in QGIS

line_interpolate_point($geometry,$length/2), respectively $length/2 should work fine, see: Note that MultiLineStrings do not necessarily have a logical order of their paths, so the center of it may ...
MrXsquared's user avatar
  • 35.6k
3 votes
Accepted

"Object has invalid geometry and was skipped" error when dissolving layer in QGIS

I found a tool in the toolbox. Its name is Fix Geometries, which fixes geometry errors automatically. The answer is here.
Paulo Matias Montecinos Medel's user avatar
3 votes
Accepted

Getting list of arrays from MultiLineString object with Python

Given your coordinates list as a shapely geometry MultiLineString object: >>> mls = shapely.geometry.MultiLineString(coords) Iterating over its .geoms attribute gives the individual ...
Spacedman's user avatar
  • 66.5k
3 votes

Does the $length function support LineStringZ in QGIS Field Calculator?

For QGIS versions lower than QGIS 3.20 No, the $length function only reports lengths from 2d geometries.
jamierob's user avatar
  • 1,603
3 votes

Getting coordinates of Line or MultiLine using PyQGIS

If you want to extract the xy of vertices of a MultiPolyline geometry you can use the following code: layer = QgsProject.instance().mapLayersByName("layerName")[0] features = layer....
ahmadhanb's user avatar
  • 41.4k
2 votes

Merging LineString with MultiLineString with Python

The shapely manual seems to suggest that you can merge LineString and MultiLineString. An approach that may work (untested) is to explode the MultiLinestring into its constituent LineStrings, you then ...
Hornbydd's user avatar
  • 44.6k
2 votes

Extracting POINT from LINE/MULTILINE-STRING

Just an example that includes an answer to the question and some more useful info: ST_GeneratePoints - Generates random MULTIPOINT inside a given geometry (12 dimensional in this case, 1996 is just a ...
viktor_vangel's user avatar
1 vote
Accepted

Folium.geojson Multiline String doesn't wrap around the map, creates crossing lines across the map

okay so I actually ended up fixing it after a few hours of struggle. First I needed to convert the javascript from the linked thread to python, change some names for my project and use the requests ...
Daltax's user avatar
  • 11
1 vote
Accepted

QGIS - Unite many lines in a single Multiline (with branches)

You can use the processing tool Dissolve
MrXsquared's user avatar
  • 35.6k
1 vote

Getting list of arrays from MultiLineString object with Python

There are several more approaches available, that are like brother and sister. the __geo_interface__ property: from shapely.geometry import MultiLineString coords = [((0.0, 0.0), (0.0, 20.0)), ((20....
Taras's user avatar
  • 34k

Only top scored, non community-wiki answers of a minimum length are eligible