1

How can I automatically join all lines that intersect into the same feature?

On the image below all three lines are different features, I would like them to all be the same feature, dissolve is not what i am trying to achieve since it joins all lines even if they don't intersect.

enter image description here

EDIT

When I run Field Calculator I get an error asking me to enter a field name? I'm also quite confused to why the Windows and macOS windows look so different?

enter image description here

1 Answer 1

3

You can use the fieldcalculator for this and update the geometry with the collected geometries of lines which intersects each other. BUT the geometry type of your line layer MUST be Multiline. So be careful with that. The expression will be this one:

aggregate(layer:='layername',
aggregate:='collect',
expression:= $geometry ,
filter:=intersects($geometry,geometry(@parent)))

enter image description here

4
  • Thanks alot for the reply! I ran in to an issue. I have edited the question to include an image and with further information :)
    – Sultanen
    Jan 28, 2021 at 8:58
  • 1
    yes you are using the field calculator from the procesing toolbox. use the fieldcalculator from the Toolbar instead!!
    – eurojam
    Jan 28, 2021 at 9:30
  • Thanks, i ran this now and it works for the three intersections, now i was trying to run it on all 600 features in this map and its verry slow, the application basically hangs. Any idea what i can do about it? Eventually i need to run this on a dataset that will have 5000+ features
    – Sultanen
    Jan 28, 2021 at 23:07
  • Running it on 144 features now and QGIS is consuming a huge amount of memory, 21GB at the time of writing, my 16GB Macbook Pro is crying a bit
    – Sultanen
    Jan 28, 2021 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.