Four ways to find the length of a line in QGIS
Method One: Identify tool
Click on segment using Identify tool. Open the "Derived" section in the Identify results window.
- Select the button "Expand New Results by Default" (circled in red) -- now the "Derived" section is open by default every time you identify a feature.
- Drag and drop the Identify window on top of an open panel (such as the Layers panel) to dock it.
- Right clicking on any attribute in the Identify window (including derived attributes) gives you the option to copy the attribute value. This is useful if you need to enter the length in another program or document.
- Change the units used in the Identify tool under
Project menu > Project properties > General > Measurements
Pros: This method is quick and easy. It always displays the current length value.
Cons: You can only see the length of one segment at a time. The lengths aren't saved in the attribute table.
Method Two: Virtual Field
Use the Field calculator to add a virtual field to the layer, with the formula:
Length is calculated in the units of the layer. It's a good idea to include the units in the field title, so anyone using the table will know the units.
Pros: This always displays the current length value. You can see the lengths of all the segments in one place.
Cons: A virtual field is saved in the project, not in the layer. So if you open the same layer in a different project, the length field won't be there. In QGIS 3.0, virtual fields are buggy, and can cause error messages and occasional crashes.
Method Three: Static Field
Use the Field Calculator to add or modify a regular field. Exactly the same method as option two, except un-check the "Create virtual field" box.
Pros: You can see the lengths of all the segments in one place. The length values are permanently saved to the layer file. Won't cause error messages or crash the program if using QGIS 3.0.
Cons: This field is calculated once, and not updated automatically.
Method Four: Labels
Label the line layer using the $length function. Optional: concatenate units to label
$length || ' meters'
Use round() function to limit number of decimal places displayed:
round($length, 2) || ' meters'
Pros: Easy to see segment length at a glance. Can see the lengths of multiple segments at once.
Cons: Length isn't saved in a table anywhere. Can't copy the length value to another document.
Note: all methods are described in QGIS 3.0, but should be similar in earlier versions.