3

I have two layers:

  • contiguous polygons without properties
  • lines with the name property that overlaps the polygons

I want to get a new layer of joined polygons if they are crossed by the same line and secondly, apply the properties of the line to the underlying polygons

enter image description here

2 Answers 2

4

Use the "Join Attributes by Location" tool via Vector -> Data Management Tools -> Join Attributes by Location.

For your specific needs, I would suggest starting with the following settings:

enter image description here

1
  • 1
    I get a good result if I also activate the option in the polygon layer: Advanced Option -> Invalid feature filtering -> Skip
    – stefcud
    Oct 25, 2022 at 19:28
4

You can achieve this using a "Virtual Layer".

Go to the menu Layer > Add Layer > Add/Edit Virtual Layer... and enter the following query. Modify the name of the layers and feel free to add more line attributes.

You can then persist the layer if you wish.

SELECT ln.name, st_union(p.geometry)
FROM myLineLayer ln
JOIN myPolygonLayer p
  ON st_intersects(p.geometry, ln.geometry)
GROUP BY ln.name --only if multiple line have the same name

Your Answer

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

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