I have line segments that have the following 3 attributes (Class, start_point, end_point). I would like to merge/dissolve line segments that fall within the same class if they intersect (touch).

i.e. if the end_point of one line segment and the start_point of another line segment are the same (similar values). (NB. I would like to dissolve lines with the same class value. The dissolve field can also be a new field which will be generated when streams meet the above condition: ie they fall within the same class as well as the end_point of one segment = start_point of another segment)

Stream segments that should and others that should not be dissolved The circled numbers represent the class (order) of the streams. Each segment has a corresponding class number as shown. The segments circled in red should be dissolved separately. The same should be done for the segments circled in green. Each segment has a start_point and an end_point. For example for the segments in yellow the end_point of one segment and the start_point of the other coincide.

The lower segment circled in red should not be dissolved with the lower segment circled in green because only their end_points coincide.

How can I proceed to do this in QGIS?


2 Answers 2


It all depends what are your data looking like. One easy way is to use two steps:

  1. Vector - Geoprocessing tools - Dissolve (dissolve everything with the same class)
  2. Vector - Geometry tools - Multipart to singleparts (will brake lines which are not touching to single lines)

Please be aware this way the table values - start_point and end_point for lines after these steps will not make much value anymore. Also the result in this way will be dissolved lines if their start and end points touches of always exactly 2 lines. If they are touching out of start/end points, crossing or multi-touching (typically Y cross), these won't be dissolved after second step.

  • Thank you @Miro, This works well for most of the segments. However, some segments are dissolved that do not meet the criteria i.e. some segments join at their end_points. The requirement is to join two segments if the end_point of one segment and the start_point of another segment have similar values. Additionally, the segments dissolved should be of the same class.
    – DennisTG
    Dec 11, 2015 at 7:33
  • @DennisTG do you mean that some lines touch (but not in their start/end point) and thus shouldn't be dissolved?
    – underdark
    Dec 14, 2015 at 20:42
  • @underdark Yes, ( these are actually river segments. So they may have different start positions but they intersect at their end points. these should not be dissolved)
    – DennisTG
    Dec 14, 2015 at 20:46
  • 1
    @DennisTG Please add some example images to your question illustrating which lines should be merged and which should not to help us understand all the details of your question.
    – underdark
    Dec 14, 2015 at 20:48
  • @underdark Thank you for the tip. I have added an image of one of the sections where some segments should be dissolved/joined and other segments should not.
    – DennisTG
    Dec 14, 2015 at 21:38

@Miro, I must say thank you again. I used your approach again and found another tool that helps i.e. "split lines with lines". For every class(order) I intersect it using the next higher order. So finally the approach I used is;

  1. Dissolve (dissolve everything with the same class)

  2. Multipart to singleparts (will break lines which are not touching to single lines)

  3. Extract each class (order) of stream (therefore creating new shapefiles for each stream order)

  4. From the processing toolbox, Use the "Split lines with lines" tool - Intersect each class with a higher class.

The results are as expected.

  • I am glad it helped. I think your question in the comment is worth new question if you can't find some explaining it already here.
    – Miro
    Dec 27, 2015 at 10:16
  • @ Miro. OK, I will look through other questions. Thanks
    – DennisTG
    Dec 27, 2015 at 14:16

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.