2

I have a polygon layer that has lines showing rivers. A river with the same name attribute might be consisted of a few lines touching each other. For example, in the image below, the river consists of 4 separate lines (with the same name in the name attribute column). The small line shown in red belongs to another river with a different name.

enter image description here

I need to merge the lines with the same names together and I know ways such as merge, join by attribute etc, however I cannot simply use merging by same name because it can happen that a line belonging to the same river (thus having the same name attribute) does not intersect with the rest of the river and cannot be merged into other lines. Is there a way in QGIS 3.22.5 to unite the lines belonging to same river together (having same name attribute), but only those ones which touch in one point?

Dissolve window in QGIS 3.22: enter image description here Advanced window: enter image description here

2
  • 1
    In other words you want to dissolve by attribute and location?
    – Mayo
    Commented Jul 25, 2022 at 14:34
  • Yes, lines with same name who also touch
    – Paris
    Commented Jul 25, 2022 at 14:37

1 Answer 1

2

Use the QGIS Dissolve tool, set the parameters this way:

  • Input layer: your lines layer
  • Dissolve field(s): the river name
  • Keep disjoint features separate: True (this is in the advanced parameters section)

enter image description here

Optional if you don't see the Keep disjoint features separate option, dissolve and then run the Multipart to single parts tool.

7
  • Thanks. In the Advanced section, I do not see the option 'Keep disjoint features separate'. I see 2 options: Invalid feature filtering & Limit features processed. I am using QGIS 3.22.5-Białowieża
    – Paris
    Commented Jul 25, 2022 at 14:52
  • Thanks so much @Mayo. I added the photo of my Dissolve window to my question section since I could not add images in the comment section
    – Paris
    Commented Jul 25, 2022 at 15:02
  • As you see in the first picture, the option you mentioned is not there. The second images shows the advanced tool
    – Paris
    Commented Jul 25, 2022 at 15:03
  • 1
    I edited my answer with an option for your version.
    – Mayo
    Commented Jul 25, 2022 at 15:11
  • 1
    I think the lines don't touch exactly. I test it and it worked fine for me.
    – Mayo
    Commented Jul 25, 2022 at 15:26

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.