I have a layer with parcels ('flurstuecke') and a layer with subdivisions ('flure'). I want to digitize parcels and autogenerate the correct number of the subdivision with an attribute formular.

It works perfectly if the parcel is completely within the subdivision. It works sometimes if the parcel is touching the subdivision (having the same border). But sometimes it doesn't work.

I guess it is because I use 'contains' in my aggregate function. How could I get the corresponding subdivision-value of the subdivision-feature that is mostly overlapped by the parcel I am digitizing?

I am using this expression:

aggregate(layer:= 'flure',
          filter:=contains($geometry, geometry(@parent))

This is when the expression is working well:

enter image description here

This is when the expression is not working. It should write 001 into the "flur" field, but it is not happening.

enter image description here


1 Answer 1


I'd change the check for contains to contains($geometry,centroid(geometry(@parent))) - this way your expression should also work when you digitize a parcel/geometry which shares a border with your subdivision-layer.


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.