4

I have a shapefile of the Washington metro area, but along much of the route multiple lines run parallel to each other (see picture 1) and I need to collapse them into a single line.

I've tried creating a buffer and dissolving the result, which visually achieves what I'm looking for but ultimately I need a single shapefile line representing the center line that I can then run the qchainage process on but so far haven't been able to achieve that.

Does anyone have a way to achieve this in QGIS?

I believe I'm essentially trying to replicate the 'Collapse Dual Lines To Centerline' functionality in ArcGIS.

Input shapefile:

enter image description here

Dissolve Buffer result: enter image description here

csk
  • 24,827
  • 3
  • 32
  • 70
Jsangster
  • 41
  • 1
  • 2
  • 2
    Why don't you simply only use the middle line and delete the rest? Yeah, I am lazy, I know... – Erik Jun 29 '18 at 14:47
  • Possible duplicate of Merging close lines? – Erik Jun 29 '18 at 14:49
  • Hi Erik, this is just a small snapshot of a much large file, some lines extend further than others so it wouldn't really be feasible to do it manually!! (i wish it was)

    I did see the merging close lines thread, but wasn't able to follow second part of the answer (below), so clarification required please!

    "import the layer into a postgis database and create the middle line using ST_ApproximateMedialAxis() function: SELECT ST_ApproximateMedialAxis(geom) AS geom INTO road_centre_line FROM road_buffer"

    – Jsangster Jun 29 '18 at 14:53
  • If you're working with QGIS 3.0 and geopackages, that should not be necessary, since geopackages are supposed to be editable by SQL-commands. – Erik Jun 29 '18 at 15:26
  • Erik, could you elaborate on how to apply that function? Novice user here. – Jsangster Jun 29 '18 at 15:32
  • I can't simply tell you how SQL works, that's at least 4 hours of university course. Dig into it yourself, so you really understand it, it'll be worth it. – Erik Jun 29 '18 at 15:38
  • I'm not asking how SQL works - i can write SQL, but what i can't do is implement the suggestion given above. Some direction would be very helpful. – Jsangster Jun 29 '18 at 16:05
  • You should edit your question to explain how you tried to implement the solution suggested, and where you got stuck. – csk Jun 29 '18 at 17:20
  • The second part, extraction of center-line, is called Skeletonization. If it does not have to be QGIS, you could try OpenJUMP. (1) Drag and drop the dissolved polygon onto OpenJUMP window. (2) Go to Plugins | Graph | Skelton and click on [OK]...done. – Kazuhito Jul 01 '18 at 19:53
  • If the distance is constant or there is a maximum of 3 lines, you can use a buffer, count the number of lines that falls within a buffer and select the buffer with the most joins. From this select the source line with corresponding attribute. Hopefully you have attributes to 'group' and distinguish them. – Al rl Feb 21 '21 at 22:05

1 Answers1

1

I have a function that returns a parallel line from three parameters, a line object, a left or right, and a distance. The returned line is parallel to the left or right of the given line a distance of the given distance.

The function takes each node of the given line and computes the center of a tangent circle (90 degrees to left or right of the current bearing) with a radius of the given distance and uses the center of the circle as the node's parallel point.

After the function returns the new line, I reverse order the the nodes of the returned parallel line if its drawn direction does not match the given line.

For street center lines, the original line must accommodate extensions to intersections.

Paul Kranz
  • 79
  • 2