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

3 Answers 3


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.


"intersect"  =  'YES' 

In addition to artwork21's answer, you can now also use the refFunctions plugin which does this job "on the fly". But of course this will cost some performance during rendering depending on the amount of features (This function is also limited to 100000 features).

In your layer, you wish to label, create a rule based label. Use this expression as filter: geomintersects('nameofpolygonlayer', '$geometry' )

Replace nameofpolygonlayer with the layer name of the layer which should be intersected.

enter image description here


In QGis 1.8 there is the option to only label selected features. Maybe you can perform your task with that?

  1. Configure Layers with wanted labelling, selecting the "only label selected features" checkbox.
  2. Create your selection
  3. Et voila!
  • 1
    Hello, Yes this is a solution I've tried. BUT 3 problems: -this option is not available in 1.9 master (I think); -need to "hide" selection color for printing; -need to select object in each layer (5) manually (a bit long). Looking for a unique solution if possible. Cheers
    – Arthur
    Commented Aug 8, 2013 at 8:40

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.