5

I have two layers and I want to join the attribute of them together in QGIS. Unfortunately, the overlapping layer (The Blue one) is not very precise, so there are parts that overlap on small areas.

enter image description here

If I join the attributes together (-> join type: intersects/one to many), I get multiple overlapping attributes. But i only want the attributes with the biggest overlapping area, which would be those:

enter image description here

If join the attributes together with the one to one method, I often get the attribute of the small overlapping parts, which i don't need/are wrong. I know I can get the mean attributes of all overlapping areas with the "Join Attributes by Location (summary)" function, which is partly a solution to my problem.

But what I really want is to only join the attribute with the biggest overlapping area. Any idea how to do this?

1
  • You could run an intersect, calculate $area for this intersect, then join attributes by location the intersect to your original yellowish layer and finally select by attribute the geometry with the largest joined area for each geometry with an identical ID (provided, you have IDs on your yellowish layer in the first place).
    – Erik
    Jul 21, 2020 at 10:20

2 Answers 2

13

Since QGIS 3.12 (see the Changelog for more details) the "Join Attributes by Location" algorithm from the Processing Toolbox (Ctrl+Alt+T) has a switch to do exactly this:

enter image description here

The type of the final joined layer. One of:

0 — Create separate feature for each matching feature (one-to-many)

1 — Take attributes of the first matching feature only (one-to-one)

2 — Take attributes of the feature with largest overlap only (one-to-one)
2
  • 1
    Is it new ? I had a similar problem and I'm pretty sure QGIS wasn't any help.. I wrote a python script with geopandas (so I can make use of multiprocessing)
    – vidlb
    Jul 22, 2020 at 21:22
  • 2
    I think it was introduced in 3.12
    – ndawson
    Jul 22, 2020 at 22:15
3

In QGIS there is a plugin called "Select Within".

But building on that I developed my own model to join based on the layer centroids by converting the layer to centroids and then join that table... Works a treat.

0

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.