3

I have two types of areas, one with smaller divisions and one with bigger divisions, and the bigger divisions completely follow the boundaries of the smaller ones.

I want to calculate the mean of the values from the smaller divisions to the bigger ones.

I have tried all the geometric predicates in Join attributes by location summary and all the other ones except for intersect return no geometry at all(or very few geometries), even when I do different combinations.

Intersect does return geometry but it calculates the mean for neighbouring areas as well, which I dont want.

See screenshots. Yes I could delete these manually but I would like to understand why it does this, because this isnt the first time this happens.

Is there a way of setting it up so it only calculates the mean for those areas that comepletely overlap with my smaller areas?

Smaller areas Bigger areas Bigger areas on top of the smaller areas - illustrating that the smaller divisions are inside the boundaries of the bigger ones Green colour for areas that have a calculated mean.

7
  • 1
    Can you provide more details and illustrate the two types of geometries you refer to, are they in different layers ? From what you mention, Contain looks like what you would need, what do you get with that on sample data ?
    – Kasper
    Jan 2 at 11:21
  • I added more screenshots. the two types of geomtries/areas are on different layers. In case of using contain it only returns a few geometries here and there.
    – Selma
    Jan 2 at 11:35
  • Screenshots are OK, sharing sample data would be better
    – Babel
    Jan 2 at 11:37
  • 1
    The easiest thing would probably to create points on surface for the smaller divisions and then using the predicate within/contains.
    – MrXsquared
    Jan 2 at 11:44
  • 1
    Sharing sample data: upload to a cloud service and share the link here
    – Babel
    Jan 2 at 11:54

1 Answer 1

1

Solution

Apply a (very small) negative buffer around the small polygons (Menu Vector > Geoprocessing Tools > Buffer). Like this, you have a guarantee that they are completely within the larger polygons. Then use the buffered layer for Join attributes by location summary.

Background/explanation

The problem seems to be that the larger areas are not completele identical with the smaller one, even if it looks so. For testing purpose, I created a hexagon grid with small grid cells, then selected a few of them, merged them and pasted it as a new layer. So the borders of the larger layer should be 100% identical with those of the smaller ones from which it was generated.

Still, using select by Location, I get the same problem as you: geometric predicates do not work reliably and - based on which predicate I select - select too many or too few of the smaller ones (see screenshot). Predicate are within worked fine in this example, but depending on your data might not work in your case. So use the negative buffer solution to be sure the smaller polygons are completely within the larger ones.

Example/screenshot

Large polygon (with red outlined boundary), created by merging small cells (blue). Still, geometric predicate intersect selects too many cells (left image). With a small buffer, you get the correct result (right): enter image description here

1
  • 1
    Thank you! This solved another problem I was having as well.
    – Selma
    Jan 2 at 11:59

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.