[GIS] Showing just some labels based on feature intersection of layers using QGIS

labelingqgis

I'm trying to use "expression based" labeling in QGIS, but I'm stuck with a particular case.

I managed to use it for a project with the help of other topics and FAQ but I'm not skilled enough to take care of this problem alone.

I have 5 layers, one "project" layer with around 10 objects (10 different marinas around rivers in France) and 4 layers for particular water area (different scales) with also polygons. I want to only show labels of those 4 last layers of the polygons that intersect any of my 10 objects of layer 1.

What query do I need to use?

Note: I already used the vector selection option and created a new layer with the selection. I'm looking for another option, label based because this is too long. I know there is also a "show/hide" option, but it is not very simple to use in my opinion.

enter image description here

Best Answer

Here is an option to only label intersected features:

  1. For each layer that you want to label add another field in the table called something like "intersect"
  2. Run a Spatial Query on each layer to define those features that intersect the project layer
  3. Use Field Calculator to populate a "Yes" value for the selected features (save edits per layer)
  4. Create label expression for each layer e.g.

Expression

"intersect"  =  'YES'