1

I have a polyline layer with 1638 features representing a road network. Each feature is a line segment which may or may not share one or both endpoints (vertices) with an adjacent line segment.

I would like to somehow aggregate these segments where the vertices are coincident, where there are 4 features representing end-to-end polyline where the vertices of each segment touch, these should be aggregated into one feature.

How can I do this within QGIS?

I have tried SinglePart to MultiPart tool but this accomplishes something similar to a general dissolve where the individual LineString features become one big MultiLineString and I only get one record in my attribute table.

Instead, I would like for the LineStrings to get aggregated into yet longer LineStrings where coincident vertices occur. I am also open to python solutions, notably using the qgis library.

EDIT

It turns out that the correct sequence is:

  • Dissolve
  • MultiPart to SinglePart

Which also illustrates that there is a difference between Dissolve and SinglePart to MultiPart tools as addressed here. But unfortunately you run into another problem as shown in the following figure:

enter image description here

The line segments coincide at exactly the same point as proven by exportToWkt() method (see this question also)

371119.89580000005662441 4688236.42149999924004078
371119.89580000005662441 4688236.42149999924004078
371119.89580000005662441 4688236.42149999924004078

Yet somehow the algorithm gets "confused" here and isn't sure which lines to connect, (1 and 3, leaving 2 out? 2 and 3, leaving 1 out). The algorithm seems to also separate where more than 2 lines contain the same coordinate.

In my version I would like it to default to the "longest" line, such that 1 and 3 are merged into one feature, leaving 2 out (1 and 3 add up to a greater length than any other combination).

Is there an "enhanced multipart to singlepart tool that can help me accomplish this?

0

Your Answer

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

Browse other questions tagged or ask your own question.