3

I have a problem. I have a road-network dataset that has topological intersection where it's not supposed to be (see picture below). To solve this, what I want to do is to erase overlapping vertexes between line-features if they are not a start or end vertex of each line.

enter image description here

The dataset it stored as a geopackage. Does anyone have a solution? Perhaps some sql-lite or Python solution? I work in QGIS and also have FME at my disposal.

Any ideas?

Lilium
  • 1,057
  • 1
  • 6
  • 17
  • 2
    The quickest way would be https://docs.qgis.org/2.14/en/docs/training_manual/processing/generalize.html ; as for removing only duplicate vertices, I would convert lines to points, buffer the points by a few inches, dissolve then spatially join the vertex point with buffers, use the buffers that have a count of two to iteratively select the source lines and finally if the count of lines is 2 (not a terminating line) remove the vertex that intersects the polygon. That's a fair bit more code than is normal for this site so have a go yourself and post if you have a more specific problem. – Michael Stimson Mar 24 '22 at 07:28
  • Are they lines or multilines – BERA Mar 24 '22 at 11:08
  • @MichaelStimson Thanks for the hint will try. – ConcreteJungle Mar 24 '22 at 11:39
  • @BERA they are lines. – ConcreteJungle Mar 24 '22 at 11:39
  • Identify overlapping points (e.g. using overlay functions of QGIS expressions), than create very small buffers around these points and create the difference of the lines and the buffers, effectively cutting the lines (creating a gap) where you have double vertices. Then re-connect the lines, based on a common id attribute. – Babel Mar 24 '22 at 21:35
  • However, the problem remains: how to differntiate between real and wrong crossings? – Babel Mar 24 '22 at 21:36
  • @Babel Your getting into something good here. I tried it. However, the difference analysis in qgis resulted in a multi-line. But i guess they can be forced into single lines. How do i automate re-connecting the lines based on a common ID? any ideas? – ConcreteJungle Mar 25 '22 at 09:52
  • Menu Vector > Geometry Tools > Multipart to Single parts. But I see the problem. Maybe a different workflow: convert the buffers to lines, then split the network lines with the buffer lines using Split with lines and then delete the vertex in the middle of the buffer. For this last step see e.g. https://gis.stackexchange.com/q/424773/88814 – Babel Mar 25 '22 at 10:34
  • Did you have a look at the networks plugin? https://github.com/crocovert/networks/ Not sure if it can help, however. – Babel Mar 25 '22 at 10:38

2 Answers2

5

If you have FME I think it's quite easy. I would use a LineOnLineOverlayer to extract the intersection points and in parallel a TopologyBuilder to extract the end points. The TopologyBuilder has a setting that allows extracting end nodes only:

enter image description here

Then match both sets (PointOnPointOverlayer/Matcher/SpatialFilter etc.) and get the intersection points which are not end points

fgiron
  • 159
  • 6
3
  1. Extract vertices

  2. Find double vertices (those you want to delete: there might be crossings you want to keep). Use e.g. Select by expression with overlay_nearest(@layer, max_distance:=0.01).

  3. Create (very) small buffers around the vertices you want to delete. 0.1 m should be enough.

  4. Convert the buffers from polygons to lines.

  5. Use Menu Processing > Toolbox > Split with lines to split the network layer with the buffer lines from step 4.

  6. Select the lines from the splitted network that are inside the buffer. Use Select by location with parameters Split - are within - Buffer (you might need to slightly expand/buffer the initial buffers to get all lines).

  7. Create new lines, connecting start- with end-point of the lines from step 6: like this, the vertex in the middle will be deleted. Use Geometry by expression for selected features only with the expression make_line (start_point ($geometry),end_point ($geometry)).

  8. In the split layer from step 5, delete the lines selected in step 6 and paste the lines from step 7. You're done.

Black lines: initial network; blue lines: buffer; red lines: final network; white dots: vertices (nodes) of the final network enter image description here

One of the crossings in detail. Red lines do not have a common vertex any more. Geometry is slightly changed, topology not. To keep geometry changes insignificantly small, choose a very small buffer size. If the buffer is 10 cm, I guess the difference in distance is insignificant for most tasks. enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208
  • 1
    Perfect, that workflow did work. I had some problems with duplicate vertices after the geometry by expression process but it got solved. Thanks a alot! – ConcreteJungle Mar 25 '22 at 12:57