1

It seems like I got the same problem which is discussed in this thread. But since it's 2 years old already, there's an easy solution to this by now?

I'm joining a vector layer which contains seperat buildings with values to a grid with the algorithm "join attributes by location (summary)". My "summaries to calculate" option is "sum". Now my problem is, sometimes the buildings cross the line of a rectangle of the grid (see image). In these cases, the building gets recognized twice and thus the resulting sum of the layer is higher than it should be. My question is, how can I tell QGIS to put the buildings each only in one grid if they're set in two? The best solution would be, if the buildings would automatically be set in the square where the most of it is in.

enter image description here

2
  • 2
    Maybe use the centroids of each building as the absolute reference for its location Commented Apr 19, 2021 at 9:47
  • Man...you are right, of course, why didn't I think of this? I already had the centroids because I created a heatmap as well. Thank you.
    – Jonas
    Commented Apr 19, 2021 at 9:59

1 Answer 1

3

You can simply create a new layer with the centroids of your builings, using Geometry by expression (see how to do it). Then join the centroids.

enter image description here

2
  • 2
    I'm a bit embarassed that I didn't think of this myself since I also already created a heatmap with the same data and thus already had the centroids...thank you very much! Also, I found that I get almost similar results if I use "overlaps" as geometric predicate instead of "intersects".
    – Jonas
    Commented Apr 19, 2021 at 10:01
  • 2
    Hey, sometimes it takes someone else to look at your project to see the obvious - that happened to me as well. That's why this site is for.
    – Babel
    Commented Apr 19, 2021 at 10:10

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.