2

I created a buffer around points and then merged these buffers to eliminate overlaps. Now I want to calculate the exact length of tracks within this area. It might be the case that at some points the lines to intersect with the trade area (I need to cut it there).

Any idea on how to succeed?

I already tried the "Sum Line Length" Tool but didn't succeed.

Example

  • 1
    Clip the lines based on the buffer, then use $length to create a new field via the field calculator. Then every line within the buffer area has it's length printed as an attribute. – Erik May 14 at 9:24
2

Tested on QGIS 2.18 and QGIS 3.4

I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume we have seven features in "roads" (lite lilac lines) and one "buffer" (light yellow polygon) accordingly, see image below.

Example

With the following Query, it is possible to achieve the result

SELECT r.*, st_length(st_intersection(r.geometry,b.geometry)) AS L_r_in_b
FROM roads as r, buffer as b
WHERE ST_Intersects(r.geometry,b.geometry)

The output Virtual Layer will create the same roads including additional attribute 'the exact length of tracks within the buffer'.

Result_AT


References:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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