I found this article which describes the "QGIS GUI way" for calculating the line lengths. http://www.qgistutorials.com/en/docs/calculating_line_lengths.html
How can I calculate the length of one line (feature) in a vector layer with Python code?
As an example, I want to know the length of the yellow line.
Answer
From the QGIS Documents: Geometry Handling, you can use the following code to get the length of any selected line(s):
layer = qgis.utils.iface.activeLayer()
features = layer.selectedFeatures()
for f in features:
geom = f.geometry()
print "Length:", geom.length()
Hope this helps!
No comments:
Post a Comment