I have this print layout in QGIS print composer/atlas in which I only have one layer being shown: land parcels. I am interested in having a label that will show what is the attribute of another layer I have based on a spatial relationship like intersects.

This other layer is a layer of land uses. The idea is to have next to the map what are the allowed uses for that particular plot. The image below recreates what I need.

enter image description here

It seems there is no straight way to build this expression within the context of the QGIS Print Composer, but I think I am missing something. The closest I got an expression that feeds my label object is this expression:

if(intersects(@atlas_geometry, geometry(get_feature('land_use', "fid", "fid" > 0))),
  'No restriction')

However this expression is always returning No restriction and this I am absolutely sure it cannot be. Therefore, this leads me to believe the intersects part is not being evaluated as I think it is. What could be wrong here?


This can be achieved using an agregate function. In this case the expression is:

 layer:= 'land_use',
 expression:= land_use,
 concatenator:=' ',
 filter:=intersects($geometry, @atlas_geometry)

Two notes on this. (1) Most of the credit goes to Ujaval Gandhi thanks to this blog entry. (2) I find it a bit counter-intuive that a non aggregation problem is solved using an aggregate. Still curious to know if alternative solutions exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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