I have a vector shapefile of river networks, where each reach in the networks has its own row in the attribute table. I want to add a grouping column to the attribute table indicating which network the reach belongs to, e.g.:

a two network example: enter image description here

and my attribute table:

enter image description here

I would like an additional column in the attribute table called "network" which would be filled with 1, 2, ....n indicating which network the given reach belongs to (in the example above "network" would be 1 or 2 since there are only two networks), it doesn't matter which network is 1 and which is 2.

  • If you have only 2 networks, select all features in one network, and use field calculator to create new field (column) with value 1 and only update selected features checked. After that just invert selection and use field calculator to updated selected to value 2 for the previously created field.
    – Miro
    Commented Oct 26, 2021 at 22:36
  • I should have stated this is just toy data, I am working with many networks.
    – flee
    Commented Oct 26, 2021 at 22:36

1 Answer 1

  1. Apply a buffer around the line (network) layer and dissolve it. Convert the buffers from Multipart to single parts.

  2. Create a unique id on the buffer layer with field calculator and $id. Than add this id to the line layer with Join attributes by location (see screenshot).

Buffer layer in orange and resulting line layer in black with id added to label the network lines: enter image description here

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.