Feature request #3843

Rule based labeling

Added by Nathan Woodrow over 11 years ago. Updated over 7 years ago.

Pull Request or Patch supplied:No Resolution:fixed/implemented
Easy fix?:No Copied to github as #:13901


I think it would be a cool idea to have rule based labeling, something like we already have for the styling.

I had a case today that it would be good to label the main trunk lines (anything diameter > 350mm) of a stormwater network in red and bold and anything less in light gray so it's less distracting but it's still visible.

The lines were already styled using the rules to show a different scale but having rules on the labels would be very handy.

Related issues

Related to QGIS Application - Feature request #8925: Saving label information/styles into an SLD File Closed 2013-10-21
Duplicated by QGIS Application - Feature request #4840: New feature: Being able to have more than one labeling fe... Closed 2012-01-19
Duplicated by QGIS Application - Feature request #5056: Allow labeling based on query Closed 2012-02-19


#1 Updated by Andrew Chapman over 11 years ago

I also regularly miss this feature. In the UK, the Ordnance Survey text layers have attributes that could potentially be used - currently one can only use them to select & save sub-sets of a layer then style as a new layer. One text layer can easily expand to 20... and with possibly 20 tiles, layer count and management starts to get out of hand.

#2 Updated by Giovanni Manghi over 11 years ago

  • Assignee deleted (nobody -)
  • Priority changed from Low to High
  • Target version deleted (Version 1.7.0)
  • Must fix deleted (No)
  • Operating System deleted (All)
  • Pull Request or Patch supplied set to No

I agree that this is a important missing feature... now we have the rule based renderer is not hard to imagine how powerful the combo would be.

See also #3796

#3 Updated by Sandro Santilli over 11 years ago

The cherry-on-cake would then be associating "rules" to "legend items" so that you can toggle visibility of single classes (both for features and labels).
Having that would completely replace my current hack described in issue #3796 for having multiple, optionally visible, labels per layer.

#4 Updated by Sandro Santilli over 11 years ago

Also, in order for this to be satisfying for the need expressed in #3796, every label "class" will need to be configurable as a single label currently is (scale based visibility, placement, style etc.)

#5 Updated by Giovanni Manghi about 11 years ago

  • Target version set to Version 1.7.4

#6 Updated by Sandro Santilli about 11 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0

Surely not for 1.7, not sure if 1.8 is a good target or features should all be moved to 2.0 directly

#7 Updated by Giovanni Manghi almost 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#8 Updated by Paolo Cavallini over 10 years ago

  • Category changed from Map Canvas to Labelling

#9 Updated by Regis Haubourg almost 10 years ago

Should we move it to 2.1?

#10 Updated by Paolo Cavallini over 9 years ago

  • Target version changed from Version 2.0.0 to Future Release - High Priority

#11 Updated by Christopher Wesson over 8 years ago

Another example: styling a road number as a 'shield' and road name as text both off the same line feature... same request as above, i.e. the ability to label one layer or feature more than once.

#12 Updated by Gavin Fleming over 8 years ago

another use case: labelling property boundaries with bearing above the line and distance below the line. At the moment the layer has to be brought in twice to do this.

#13 Updated by Schalk Grobbelaar almost 8 years ago

Gavin Fleming wrote:

another use case: labelling property boundaries with bearing above the line and distance below the line. At the moment the layer has to be brought in twice to do this.

Agree Gavin. This issue was opened 4 years ago and up to today it is still missing. I use this a lot and that is the thing that I talked about in that meeting with you and Tim where QGIS is lacking a lot of powerful SLD functions. In my use case: I, for example have different Rules based on different scales. Lets say I have a Layer (Provinces) that contains 2 fields (abbr and prov_name). I start of by showing the abbreviation field (abbr) as the label (Rule 1) and as the user zooms in he/she sees the prov_name (Rule 2) on another scale. This cannot be done in QGIS, only in Geoserver by editing the XML by hand (which takes a lot of time). The only thing missing here is to have an interface where you can also set label settings per rule which creates the <se:TextSymbolizer> under <se:Rule>.

I will really appreciate it if someone can come up with a solution for this.

#14 Updated by Paolo Cavallini almost 8 years ago

Please consider sponsoring a fix for this, if it is really important for you. Please ask if you are interested, and need advice.

#15 Updated by Andreas Neumann over 7 years ago

I agree with Paolo.

Someone who really needs this should step up and sponsor this feature or it won't be solved for another five years.

Introducing labeling rules is not a small feature that can be implemented in one evening. It requires several days of work. If no one pays for it or implements it by himself, it won't happen.

The majority of the recent new features in the past releases were paid development.

You can expect smaller issues to be solved by someone in his leisure time, but not bigger ones.

#16 Updated by Nyall Dawson over 7 years ago

  • Status changed from Open to Closed
  • Resolution set to fixed/implemented

Implemented in 2.12

Also available in: Atom PDF