4

I see that it is possible to create an abbreviations list, by using 'Apply label text substitutes' in the Labels Properties, but this abbreviates ALL labels. Is there a way to use the abbreviations only when required, ie. to fit labels on shorter roads and not abbreviate when there is enough room to show the full label?

3

you can use expression tool to build your label. You have to put your abbreviation in a field of the table, i.e. named "abbreviation".

With expression tool, that you find next to the label properties nemed "label with", you can set an expression to show abbreviation if the line string is lower than a length. For example if you want use abbreviation for line lower than 100 m you have to write:

CASE 
    WHEN  $length < 100 THEN  "abbreviation" 
    else  "normal name" 
END

CASE operator checks if the line length is lower than 100 and if the test will return TRUE then it sets the label with the value in the "abbreviation" field else with the value in the "normal name" field.

You can also use this test:

CASE 
    WHEN  $length < (length("name") * 10) THEN  "abbreviation" 
    else  "normal name" 
END

in this example it is supposed that the font size is 10 meters (it depends how you have set this parameter in the label properties). If the line length is lower than label length (in meters) then the label is set with the "abbreviation" else with the "normal name"

| improve this answer | |
  • Hi Enrico Many thanks for your reply. I have tried this but come across a new problem. The road data that I am using is broken into sections between junctions. I have checked the box under 'Rendering' to 'Merge connected lines to avoid duplicate labels'. Using the expression that you have suggested, it seems to override the 'Merge' function in some areas and I get unnecessary repeats, but not in all instances? – Sean McVeigh Sep 29 '17 at 11:34
  • Hi, to resolve the issue you can try to dissolve the line and than covert them in multipart geometry (you find this tools in Processing toolbox). You can use the field with the name as unique value field. – Enrico Fiore Sep 29 '17 at 12:53

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.