3

I would like to show as many street name/label as possible on the print composer map, without overlapping, automatically change each label’s style, if it is necessary, depending on what is possible to display.

The default label is curved, 8p (Liberation Sans), but if the QGIS can't show a label (because of any reason), then the style of label of that street should change to a narrow font (Liberation Sans Narrow). If it is not possible at all to show a label in curve, then it should change to parallel label.

Summarize (for each label on the layer):

  • If it is possible to show: Curved Label, normal font
  • Else if it is possible to show: Curved Label, narrow font
  • Else if it is possible to show: Parallel Label, narrow font
  • Else: Parallel Label (just the first 3 character and a ‘.’ For example: “Main street” -> “Mai.”)

How is it possible in QGIS?

3

Unfortunately I don't think it is possible to set visibility conditions this way.

Your only option is a binary choice: show colliding labels, or hide colliding labels:

enter image description here

Ideally, the expression builder would have a variable or function to test whether a given label will be displayed or hidden. If QGIS had such a variable, you could use data-defined settings like if( labels_collide = 'true', ... , ...).

It might be possible to create a custom function. Once created, you can load a custom function into QGIS and it will be available in the Expression Builder alongside the standard functions. I don't know how to do this, but I think it's possible. If you want to learn more, here are a few links that to get you started:

  • I can't find any variable or function for this purpose. A custom function would be a good solution, but I don't know how to do it exactly. – Aaron Petri Mar 13 at 17:05
  • 2
    Yep. That's exactly what I concluded. Basically, your options are (1) Accept that QGIS doesn't have the feature you want, and learn to live with it; (2) Learn to code, and create it yourself; or (3) Someone else also wants the same feature, so they create it. You can make a feature request, and maybe option 3 will come true. It seems like it would be difficult (aka expensive), but it also seems like a feature other people would want, and therefore might donate money to a crowdfunding campaign (Like this one, which led to a new feature in QGIS 3.) – csk Mar 13 at 17:27

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.