I am using the QGIS expression builder for the label properties of my data.

Is it possible to put different parts of the label in different coordinates on the map?

For instance I have a linestring and I would like to have "A" displayed in the beginning of the linestring and "B" in the end of it.


One method is to use Rule-based labelling and adding two rules for "A" and "B".

  1. Go to Layer Properties > Labels and change the option No labels to Rule-based labelling. Then add a rule by clicking the green plus icon:

    Rule-based labelling

  2. Set the relevant options as shown such as Label with (use something 'A') and the Coordinate X Y. For the x-coordinate, click Edit... and use $x_at(0) to place the label at the start of the linestring; for the y-coordinate, use $y_at(0).

    Rule options

  3. Repeat Step 2 for "B" but for the x-y-coordinates, use $x_at(-1) and $y_at(-1) respectively for the end of the linestring.

  4. When you click Apply, hopefully you should see something like this:

    Lines with labels

  • 1
    Thanks for sharing your solution! I will take a closer look at it. I am quite new at QGIS and the learning curve is still in its beginning. – benoitespinola Aug 4 '16 at 13:20
  • @benoitespinola - Apologies for not responding (I normally reply to comments)! Most welcome and I'm sure you will get used to QGIS very quickly :) – Joseph Aug 30 '16 at 15:19

There is an alternative way of doing this using symbology rather than labelling which might work for you:

- If you want different text for different features then add two fields to your data, one for your end text and one for you start text. This isn't necessary if you want just 'A' and 'B' at the ends of the lines.

  • Symbolise your line layer and then add a new symbol layer -> set this to a marker line on the first vertex
  • Set the symbol type to a Font Marker
  • Either set the marker to 'A' or set the value to match the start field from your layers attribute table
  • Muck about with size and rotation etc as you would a standard marker.

Repeat to add the end 'label'.

enter image description here

  • Nice! Thanks for your solution! I will try it out as well. :) – benoitespinola Aug 4 '16 at 13:22

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.