1

I use the Service area (from layer) tool in QGIS (3.34), which allows to output the boundary nodes. I was expecting that this tool only returns the nodes at all dangles of the calculated service area lines, but I get the dangles plus all other vertices of the service area (as one multipoint geometry). This seems like a bug to me—or I have the wrong understanding of "boundary nodes".

What is the most performant way to only get the service area dangles as nodes?

What I have tried so far


Tara's solution here (version 1)

Result with visible errors:

Tara's solution with errors

Based on this model


BERA's solution here (version 2)

Same result with errors.

Based on this model


Babel's solution here (version 3)

All service area vertices remain. Obviously I am still missing something.

Based on this model


You can find the complete test data here

4
  • 1
    You want to find all end points of the service area(s)?
    – Bera
    Commented Nov 19, 2023 at 8:49
  • Exactly, that's what I'm looking for. Should I better use the term "end points", as "dangles" might be misleading?
    – winnewoerp
    Commented Nov 19, 2023 at 8:50
  • 1
    Alternatives to finding dangles: gis.stackexchange.com/a/427802/88814 and gis.stackexchange.com/a/444603/88814
    – Babel
    Commented Nov 19, 2023 at 8:54
  • Thank's for the links. See my edited question. I tried different things, but the results are faulty in each case so far, unfortunately. :(
    – winnewoerp
    Commented Nov 19, 2023 at 10:24

3 Answers 3

6

Try this:

  1. Explode lines on Service area layer, to create a line for each line segment.
  2. Create a spatial index on the exploded lines.
  3. Extract the vertices from the exploded lines.
  4. Buffer the vertices with a small distance, I use 5 m.
  5. Sum line lengths with the buffer output as Polygons and the indexed layer as Lines layer. Output will be a duplicate of the Buffer layer but with a Count attribute with the number of exploded lines intersecting each buffer.
  6. Extract polygons by expression "COUNT"=1, to extract the end points which will only have one line to it.
  7. Extract the vertices intersecting the extracted polygons:

enter image description here

My line network have some duplicate lines so all end points arent found. Maybe your line layer is better..:

enter image description here

3
  • Thank you, @BERA. The problem is, that the resulting service area always includes duplicate edges (at least in my case) when exploded to single lines. So I had to extend your solution, as you can see in my new answer: gis.stackexchange.com/a/470573/52808
    – winnewoerp
    Commented Nov 20, 2023 at 0:41
  • What do you mean by that exactly? I tested different versions to drop duplicate geometries from the service area - without success.
    – winnewoerp
    Commented Nov 20, 2023 at 6:07
  • 1
    OK. But the problem is that after your model, there are already many points missing (like in your screenshots) and I don't see how dropping duplicates might help here.
    – winnewoerp
    Commented Nov 20, 2023 at 6:19
3

Due to the problem that service areas (almost) always contain duplicate line segments, it had to be solved like this as an extended version of BERA's answer:


  1. "Explode lines" of service area
  2. "Extract vertices" of the exploded lines
  3. Create a minimal "Buffer" for the extracted vertices
  4. "Sum line lengths" of minimal "Buffer" and result from "Explode lines"
  5. "Join attributes by location" (intersect) of "Extract vertices" and "Sum line lengths" results
  6. "Extract by expression" (count=1) from result of "Join attributes by location"
  7. "Extract by expression" (count=2) from result of "Join attributes by location"

  1. "Extract specific vertices" from original network layer (0,-1 for start point end end point of each line segment)
  2. Add a minimal "Buffer" to the extracted network vertices
  3. Perform an "Intersection" of the "Extract by expression" count=2 result from above

  1. "Merge vector layers" of the intersection result and the result of "Extract by expression" count=1 result from above.

Screenshot of the graphical model

Screenshot of final result

This is due to the fact that because of overlapping line segments in the calculated service area, all vertices that are corresponding end points and end points in the original network have a count of 2, whereas all service area vertices that have no counterparts in the original network because they area located between its vertices have a count of 1. Thus, the vertices with a count of 2 only have to be kept if they correspond to a start point or an end point of the original network. See the following screenshot (the green count=2 vertices have to be removed).

Screenshot showing count=1 and count=2 for all respective vertices

I can hardly imagine that this is the most performant way to extract all dangles of a service area in QGIS, but so far (and based on the suggestions of others) this is the only working solution that I have found (at least for my specific use case).

Please note: Have a look at

as I reason why I'm not satisfied with my own answer and thus can't accept it at the moment.

1
  • Maybe I should look for alternatives like pgr_drivingDistance() in pgRouting (e.g. gis.stackexchange.com/q/339553/52808) if better service area outputs are being created (without duplicates). I will iterate over lots of service areas in my productive workflow and with a complex model for "simple" steps like this I have serious performance problems.
    – winnewoerp
    Commented Nov 20, 2023 at 6:27
1

Here's my final solution:

Model for creating service area dangles

It is based on:

  • BERA's answer and my answer to "Remove partly overlapping geometries from service area in QGIS" (with "Snap geometries to layer" as crucial part of the fix)
  • This answer to "Finding number of lines touching intersection point (in polyline layer)"

It seems to me that this is a "cleaner" solution than this one.

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.