0

I have a layer with rule based labelling enabled. There are two label styles: a base style for all labels (no filter) and a highlight style which is intended to apply to features with a particular attribute value only ("Class" = 'Review').

Sometimes it works, sometimes it doesn't. Each time the map canvas is refreshed each feature with the 'Review' value randomly chooses either the base label style or the intended highlight label style.

Have I failed to set this up properly or is this a bug?


Rule based label implementation with style applied randomly to one feature.
Rule based label implementation with style applied randomly to one feature.

Rule failed to apply to anything.
Refresh and this time the rule failed to apply to anything.

Rule randomly applied to a different feature.
Another refresh and this time the rule randomly applied to another feature.

  • 1
    Instead of (no filter) under Rule for the Base, try to use ELSE. – ahmadhanb Nov 20 '18 at 5:00
  • Thank you ahmadhanb, that works exactly as it should. Please re-post this as an answer so I can give you a big green tick, as comments don't allow me to do this. You are a legend! – Sangster Nov 21 '18 at 2:29
1

To extend the comment as an answer, Instead of (no filter) under the Rule for the Base label, it is better to use ELSE. Without providing an ELSE statement,the labels will be assigned random styles as you have noticed already. But with ELSE as a rule you are restricting other labels to use a common specific style that you have defined to them.

2

You need to adjust your second rule: enter image description here

The "Base" label overwrites your "Review" label because (no filter) also includes "Class" = 'Review'. Set your "Base" rule to "Class" <> 'Review' to fix this or use the ELSE statement.

  • Thanks for your comment. That was my initial solution however it requires maintenance in that when additional rules are added the base needs to be updated to filter those out too. Since a system can grow to become complex and labelling rules can change I hoped to set up the base so that it would catch anything not already accounted for. – Sangster Nov 20 '18 at 3:04
  • Regarding multiple filters catching the same features, it seems reasonable that QGIS should provide consistent results in this situation. I figure it should either apply the first rule and stop processing, or apply all rules resulting in the last to be processed being the one that is seen on the canvas. So it still seems like a bug to me. – Sangster Nov 20 '18 at 3:16

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.