1

I've got a Linestrings layer.

Each Linestring has among other fields, these ones:

  id  ENTRY EXIT
    1   S1  E2
    2   S1  E3
    3   S1  E3
    4   S1  E3
    5   S1  E3
    6   S1  E1
    7   S1  E3
    8   S1  E2
    9   S2  E5
    10  S2  E3
    11  S1  E1
    12  S1  E1
    13  S3  E4
    14  S1  E2
    15  S1  E1

I want to show for each Linestring, the ENTRY value as a label at the beginning of the Linestring and the EXIT value at the ending.

Something like this (Only the red labels): enter image description here

One approach would be to create a new points layer with the beggining and ending points of each Linestring and add the data of the Linestring to each point and after that just show the labels...but, is there a way of achieving what I want using only the existing Linestring layer?

4

You can do this with two "Rule-based Labelling" labels, with no filters. This lets you put multiple labels on a feature. The first rule labels the feature with the attribute you want at the start, the second rule with the end attribute. Initially your labels will appear in the centre of the line, so we need to fix that.

Do that with "data defined" expressions for the position. Use the drop-down and hit "Edit...". For the label at the start, use x_at(0) and y_at(0) for the position expressions. For the end label, use x_at(-1) and y_at(-1). End result is:

enter image description here

  • It never stops to amaze me the power of QGIS! – Egidi May 25 '16 at 12:15
  • to increase marks, as the starting and ending points of different Lines are in the same XY, the starting Texts and the Ending Text of different Lines are placed one above another so one of them it's not seen...how could I place the label a little bit displaced through the inside of the Line and not exactly on the end/beggining? – Egidi May 25 '16 at 12:22
  • I created a new thread for my previous question: gis.stackexchange.com/questions/194904/… – Egidi May 25 '16 at 12:38

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.