I have several layers which are stagged on each other. I need to create a label (or text-window / description, doesn't matter) which should contain values from different layers. Creating a regular label I can only choose attributes from this layer. Because the features have different nodes, it is not possible to just merge the layers.

  • Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.
    – KReisser
    Feb 25, 2019 at 13:28
  • I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes
    – KReisser
    Feb 25, 2019 at 13:34

3 Answers 3


You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.

Here is an example between two line layers, but this approach can be generalized to other types.

Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:

SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)

This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.

enter image description here

  • 1
    That is magnificent!
    – Taras
    Feb 25, 2019 at 13:41
  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
    – JGH
    Feb 25, 2019 at 13:43
  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
    – Taras
    Feb 25, 2019 at 13:50
  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?
    – KReisser
    Feb 25, 2019 at 13:58
  • 1
    @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)
    – JGH
    Feb 25, 2019 at 14:09

Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:


  • Point layer named points with id and field1 fields
  • Polygon layer named poly with id field

to Create the label for the poly layer I used this:

concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


  • "id" is the ID field of poly
  • geomcontains is the function from refFunctions
  • 'points' references my points layer and
  • 'id' is the ID field of points

Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference) enter image description here

  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?
    – KReisser
    Feb 25, 2019 at 15:12
attribute( get_feature( 'layer_wth_label_field','column_name_with_cross_value_within_that_layer', 
attribute( $currentfeature, 'corresponding_column_within_labeled_layer_containing_cross_value' )),'column_containing_labeling_text')

which essentially does:

  1. within a second layer (one containing text you want to appear on labels: 'layer_wth_label_field')
  2. find the right record by:

2a) from current feature (layer 1) get the cross value (common between both tables/layers, here: attribute( $currentfeature, 'corresponding_column_within_labeled_layer_containing_cross_value'

2b) find the corresponding record in the 2nd table/layer

  1. for that record (in 2nd table) get the value from specific column

  2. put it in the label of current feature

what is worth, it's works perfectly with labeling values from both geometry and non geometry layers, as the one I connected in my picture: Qgis labels from other layer

preview how it looks (tables and labeled feature itself) Qgis cross-layer labeling - screenshot

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.