4

I have a layer called "Projet", which overlays a layer called "Parcels". enter image description here

I have a symbol render which allows me to highlight the touched parcels. enter image description here

The expression I use is: enter image description here

Is it possible in in the label of my layer "Projet" to put the number of the parcels (attribut of the layer Parcels? enter image description here

[EDIT]

So I wasn't clear enough... As you can see in the first picture, each parcel has a unique NUMBER. What I trying to do, is to get this unique number for each intersected parcels.

I try to have the number value for each centroid. On the example above (second picture), I have 4 parcels in red. So I would like 4 unique numbers, one for each centroids! Some thing like that: enter image description here

Sorry for my bad english if it's not clear enough

3
  • Your question created some confusion whether you want to label with a concatenated string of attributes, taken from the layer Parcels with numbers (my solution) or if you rather want to get the number of intersection features (solution by @MrXsquared). It would be good to edit your question accordingly. – Babel May 17 at 14:03
  • See edits above. – Stocker Antoine May 17 at 20:11
  • Sorry, I'm still confused: you want this for visualization purpose only? That means: you want to apply a label to all parcel polygons that are intersected by a polygon from projet layer? – Babel May 17 at 20:15
4

As you added more details, it seems that you're looking for something else:

To set a label only for the features in layer polygon that intersect with layer selection, open the label settings for layer polygon. Got to the Rendering tab and next to Show label use data driven override and paste this expression (available since QGIS 3.16):

overlay_intersects( 'selection')

This solution is interactive: if you change the shape of the blue polygon, labels will be automatically be changed in accordance with the new intersection.

Screenshot: only features of the orange polygon layer that intersect with the blue layer are labeled: enter image description here

Variant

You could also get the geometries of the intersecting features of the layer polygon on your layer selection using Geometry generator with this expression (see next screenshot):

collect_geometries ( overlay_intersects ('poly', $geometry ) )

However, labeling based on the orange layer like in the screenshot above is not possible afaik: labels are set based on the current layer and the blue outlined polygons created with geometry generator can not be individually adressed.

enter image description here

3
  • Ok, it could work like that… but it is not possible to do that in your « selection » layer? So that the render of highlighted the parcels and adding the labels would be done in the same layer? – Stocker Antoine May 17 at 21:13
  • 1
    Why you want to do it there? You want to label the orange layer (see screenshot), not the blue one, did I understand you right? Or do you want to label the blue layer with values from the orange layer? By the way: if you change the shape of the blue polygon, labels will be automatically changed to the new intersection. – Babel May 17 at 21:15
  • Added another explanation. But if I understood you well, what you want to achieve does not really work or make sense. Probably explained what is your final goal you want to achieve would make it clearer what and why you want to do. – Babel May 17 at 21:27
6

array_length(overlay_intersects('Parcels',$id)) should do what you are looking for.

Edit: Seeing Babel's answer I am not quite sure if I understand your question correctly, this expression counts the number of intersecting features from the layer 'Parcels'

1
  • 1
    I think the question is not clear enough - it could be either your or my solution... – Babel May 17 at 14:01
5

Use this expression to label your Projet layer with a comma-delimited string of attribute values. Replace attribute with the name of the field from where the values should come from:

array_to_string (overlay_intersects ('Parcels with numbers', attribute))

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.