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():
...
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.
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 ...
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.
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 ...
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.
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....
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 ...
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 ...
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 ...
1
vote
Accepted
QGIS - Unite many lines in a single Multiline (with branches)
You can use the processing tool Dissolve
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....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
multiline × 13qgis × 7
linestring × 4
length × 3
python × 2
postgis × 2
qgis-3 × 2
field-calculator × 2
line × 2
coordinates × 2
shapely × 2
pyqgis × 1
geojson × 1
point × 1
layers × 1
fields-attributes × 1
legend × 1
3d × 1
dissolve × 1
union × 1
list × 1
geometry-conversion × 1
folium × 1
duplication × 1
antimeridian × 1