I didn't find any answer to this question. In this post it is said that labels are by default on top of everything else: How to place labels under a vector layer?. But it was for 2.2, and years went by since then so maybe now there is the possibility...

So I would like labels of a layer to appear under symbols of another layer. For now I get a result like you can see below.

enter image description here

The blue squares with blue content is a personnalized symbol (linked to a database), and this is the main information to be displayed. The greyish number is a cadastre reference, which need to appear, but not so prominently. I also have sometimes some other labels on the same space, which I also would like to appear under the blue box. Does anyone know a way to do so directly in QGIS ?

  • Have you checked Layer | Properties | Labels | Automated placement setting already? There is Show all labels and features (including colliding objects). – Kazuhito Mar 3 '17 at 10:26
  • I did try this, but it doesn't seem to realize what I want. The only thing that may happen is that some labels would disappear when they are in conflict with some other objects. The problem is, as I understand it, in the fact that by default the labels are placed on top of everything, and I cannot figure out how to change that. – GuiOm Clair Mar 3 '17 at 10:43
  • Indeed for the linked question, I edited my post consequently. – GuiOm Clair Mar 3 '17 at 10:46
  • How did you generate the blue symbol linked to a database? Right now I'm after something similiar, perhaps you could point me the direction... – Jochen Schwarze May 2 '17 at 9:13
  • 1
    I created a symbol from lines positionned where I wanted to for the frame, and inside added some values based on variables. At the end it looks like that pasteboard.co/1nCCnD18d.png, with the last lines in fact being lines oriented and placed as I want them to (manually though). I don't know if it helps ? – GuiOm Clair May 2 '17 at 9:57

I don't think there is a way to do this in the map canvas itself. The labels will always be on top at least in QGIS 2.x.

But for the print composer, you can work with two maps. They should be in the same location and placed one on top of the other. The bottom one would have the labels and no visible features and the top ones the vector features without labels.

An example of similar can be seen below. Where the bottom most map has the labels above the insert map box (which will always be on top). This was done by having the map with the box underneath a map with the labels:

enter image description here

  • 1
    Indeed it fit my needs since the purpose is to finally print these documents. Thanks a lot ! – GuiOm Clair Mar 3 '17 at 12:00
  • Another question (maybe I should start a new topic, if you think so I'll do it) : is it possible to link the overlaying maps so that if I change the scale or the extent of one it automatically change the other one ? – GuiOm Clair Mar 6 '17 at 9:38
  • I don't think there is a way to link the scale. Although there might be with some Python. But you can link the extents by making, say the bottom map an overview map of the top one. Have it with no visible overview marker, and the "Center on overview" ticked. It will then center it on the other map, so always follow. – HeikkiVesanto Mar 6 '17 at 11:12

Here is an approach that might be useful, but lacks someway the great flexibility of layouting labels directly in QGIS.

This approach makes use of

  • the ability of cusom scripting QGIS and
  • the ability to 'data defined override' everything in QGIS

Carry out the following few steps:

Design the Labels you desire in Inkscape.

enter image description here

If you have only a (very) small amount of attribute values to label, you may consider to design one label for each value [DN 100, DN 200, ... in my example]. Otherwise, for some tens or hundreds of attribute values to labels, or if these often change, it would be no great challenge to write a custom python script, that creates an *.svg file for each attribute value by simply replacing the text occurence for the attribute values directly in the svg-file:

Example code snippet (note the last line):

     y="255.53072">DN 300</tspan></text>

In my example, the width of the white background rectangle as to be adjusted too, taking the varying attribute text length into account.

Note, that the resulting svg-files are to be named according to the attribute values, something like 300.svg, 200.svg or 80.svg in my example.

In QGIS styles I add a marker line to the styles of my layer and set it up like shown below (note the 'expression'-button right beside the svg-path):

enter image description here

An expression depending on the attribute value enables QGIS to select the correct svg-file for each value (I think it is even possible to executing a custom function that creates the svg-files directly from the expression editor, but I did not play around with that...):

enter image description here

The result is shown in the screenshot below, note the 'label' near the map centre:

enter image description here

  • Thanks, that looks like another good workaround. I am not looking into that part of my projet at the moment but I'll keep you method in mind when I'll be back at it. – GuiOm Clair May 2 '17 at 8:41

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.