4

I'm using QGIS 2.82 and 2.14 (different production workflows but same problem).

I have two layers:

  • A layer of polygons (layer1)
  • A 'buffer' layer (layer2), i.e. a single circular feature centred on a point of interest

What I want is to:

  • Render both layers
  • Only label layer1 polygon features that intersect the buffer polygon

I'm trying to use the Label -> Expression string builder with:

CASE  
WHEN intersects(layer1,layer2) THEN layer_1_label_column  
END  

I'm getting a parse error: Column 'layer1' not found

Anyone know if this is because:

  1. I haven't got the syntax right to point to the geometry in the layer (I've tried dbname.layer1.the_geom and layer1.the_geom with and without quotes);
  2. It's not possible to use a geometry function across two layers in a label expression.

I don't want to do anything that results in a permanent output (i.e. additional columns added to the layer).

1

1 Answer 1

2

An alternative is to use the refFunctions plugin which provides additional spatial functionality for using expressions. You can download/enable this by going to the menubar:

Plugins > Manage and Install Plugins...

The way the functions work is that you assign the input layer ("layer1") and call the target layer ("layer2"). But what it also does is it calls the field values of the target layer, not the input layer. So if you want to label "layer1", you will need to pass the attributes to "layer2". You can do this by using the Join attributes by location tool from the Processing Toolbox or Vector menu using "layer2" as the target layer. Let's call this output "layer3".

Now that your new buffer layer has the joined attributes, you can use a label expression for "layer1":

geomintersects( 'layer3', 'field_name' )

Result


Tested on QGIS 2.16.1-Nødebo.

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.