4

I need to know if in QGIS 3.16 there is a method to stretch a label all along line length.

My layer has lines with different length and I want to know if is possible to stretch automatically labels all along lines length, preferably using letter spacing. I've never used rule-based label and I don't know how it works, maybe I should use it to do what I want?

1
  • I thought it'd be possible using $length/length("labelcolumn") for spacing when setting the font size to map-units - but it isn't.
    – Erik
    Commented Dec 7, 2020 at 14:44

1 Answer 1

4

No, there is no completely automatic way. But you can do the following and play a little with the max and min spacing:

Set up a label and go to "Formatting":

enter image description here

Then click on the data defined override button for "word" or "letter", depending on your preference. Or choose both.

Open the assistant and enter $length as source (should work with degrees as units as well, at least in 3.16). Then load the max and min values. Finally adjust your max and min spacing. With the last setting (marked in blue) you need to play a little to find a suiting one.

enter image description here

Example result:

enter image description here

1
  • This can be a good solution thank. For now i set spacing between letters with this espression: $length/(length("des")*2) where "des" is the name that i want to label, i think even this could be a good solution
    – Giulio
    Commented Dec 8, 2020 at 16:37

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.