I am using QGIS 3.12

I am trying to find a way to plot a value above the line, at a certain distance from point 1 to the right, and at a certain distance from point 2 to the left ?

The value is coming from a attribute table where I don't want to change or add columns.

So far I used rule-based labelling, placement, data refined....but I'am not there yet... The values are positioned at the point, both begin value and end value, are now presented at the same location.... but needs to presented above next to each other.

How can I do this?

I need to make the label in XML and SLD-format

enter image description here

enter image description here

1 Answer 1


enter image description here

Step 1: Add two rules, one for each label. Actually the rules can be empty, you just need to set the correct column to be used as a label. I used length > 0 because that'll always be correct.

Step 2: Doubleclick a rule, choose the correct column to label by, maybe change the styling. Head to the placement tab and scroll to the very bottom, there you may set data-defined override of the placement. Click the left button and choose edit from the menu.

Step 3: Now the window at the bottom left popped up and you may enter an X-coordinate for your label. Enter the following:


This says: Along this geometry (line) interpolate a point which is 0.15 times the length of the line from the starting point and hand over the X-coordinate.

For the Y-coordinate insert the same expression, but exchange the leading x for an y.

Repeat for the second rule, but here use 0.85when calculating the distance along the line.

This gives you the styling in the left middle. Fiddle with the distances along the lines until you are satisfied with the placement.

Issues to be resolved: Currently the labels are horizontal and I can't get datadefined rotation to work.

Note: The picture is for completeness. You got it mostly figured out, but maybe other users didn't get that far.

Note 2: I did this in QGIS 3.10, I don't know whether the relevant expressions are available in older versions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.