3

I am using QGIS 3.10 version.

Image those two blue lines are points. How to measure the white line between those points?

enter image description here

4
  • 2
    What did you try by so far? What are your ideas? Have you seen related tutorials/topics? Btw how many distances do you need to measure?
    – Taras
    Commented Feb 22, 2021 at 5:36
  • 1
    You can use a measuring tool or digitize the line and calculate the length.
    – Frodo
    Commented Feb 22, 2021 at 6:15
  • sorry if you guys confused, i recorrect the question already. @Taras Commented Feb 22, 2021 at 6:49
  • 1
    Are you new to QGIS or to GIS in general? Please answer @Taras questions so it becomes clearer for readers.
    – Techie_Gus
    Commented Feb 22, 2021 at 7:07

4 Answers 4

4

You can use network tools from processing toolbox for this:

enter image description here

Here an example using "Shortest path (point to point)" (if you have only two points like in your example):

Just start the tool, choose your line layer as input, and shortest as path type to calculate, then click on your two points (you can enable snapping to get a more precise result, but will work without as well) and hit run:

enter image description here

You can then open the attribute table of this new layer and calculate the length, e.g. by using length($geometry) or length(transform($geometry,layer_property(@layer_name,'crs'),'EPSG:31468')) (replace EPSG:31468 with your EPSG-Code you wish to have your length in)

enter image description here

enter image description here

2

You can split the lines at points using the methods discussed here

QGIS - splitting lines at points with SAGA

OR

QGIS - Splitting lines at points using grass

Then create a field using the formula $length to calculate the length of the lines (make sure your coordinate system is projected in metres or the value you want your measurement in).

This will add a length attribute to each line section that you can view in the attribute table

2

As far as I can see, there is still no genuine QGIS algorithm to split lines with points (but as mentioned by @jdavid05, you can use GRASS or SAGA tools). However, there is an algorithm for splitting lines with another line. You can use this, converting your points to (very small) lines that are then used to split the line.

  1. Use this expression to create a new layer from the points (see here how to do it)- it basically "extends" the points to become a line: extend( make_line( $geometry, project( $geometry, 1,0 )), 1, 0 )

  2. Use Menu Processing / Toolbox / Split with lines - as input, select your original line, for Split layer select the line layer created in step 1.

  3. Now you can select the line (or lines) between the two points and measure it's lengt using field calculator: length ($geometry) (planimetric measurement) or $length (ellipsoidal measurement).

Screenshot: the black line is split at the points, the section between the points is selected. For this selection, the field calculator measures the length ($length) - see preview of the result at the bottom: enter image description here

2

Use QGIS expressions to directly calculate the length of the line segment between two points from another layer, without any geoprocessing.

Use this expression on the line layer, replace point with the name of your point layer and the numbers (2 in line 6 and 1 in line 15) are the $id values of the two points:

line_locate_point( 
    $geometry, 
    geometry (
        get_feature_by_id (
            'point',
            2
        )
    )
) -
line_locate_point( 
    $geometry, 
    geometry (
        get_feature_by_id (
            'point',
            1
        )
    )
)

Measuring the length of the red curved line segment - the length value is created as a dynamic label with the expression from above as input. As you can see (comparing with the measurement tool that returns a similar value for a comparable length) the correct value is returned: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.