[GIS] Displaying attribute value from related layer in QGIS Atlas

atlasqgisrelates

I work on QGIS 3.4.4 Madeira. I have two related layers in my project :"towns" (polygon) and "interest points" (points), the common field is "town name".

In the Atlas, my cover layer is "towns".

I would like to put labels wich display values from different fields of the child layer ("interest points") corresponding to the current entity of the Atlas. It seems easy but I can't find the correct expression.


My cover layer in the Atlas is "towns" and in each town, I have several "interest points". The layer "interest points" have many fields and I would like to insert data from a given field of the child layer using an expression in the labelling (text) tool and not the table tool. So I need an expression to insert the value inside a sentence for example.

I tried relation-aggregate function, it returns values from child layer but it necessarily "calculates" (min, max, sum…). And I only want to display the child related value.

Best Answer

I'm not sure I understand what you mean by "corresponding to the current entity of the atlas." If you mean points that intersect the current atlas feature, here's an answer:

Use Rule-Based Labeling for the point layer. Create a rule with this filter expression:

 within( $geometry , @atlas_feature )

Select the field that you want to label the point with.

You can create a separate rule for each field, or combine multiple fields into a single label. Use an expression such as this:

concat( "field1", '; ', "field2", '/', "field3", '-+-+-+-', "field4" )

The label will look like this: field1; field2/field3-+-+-+-field4. Be sure to substitute

  1. your actual field names instead of "field1", etc.
  2. the text or punctuation you want between the fields instead of '; ' and '/' and '-+-+-+-'
Related Question