Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In QGIS, I can't seem to find a way to define the features that I want to label using a SQL query? Is this possible?

For example, I downloaded the OSM Natural shapefiles, and a lot of those features have no values in their "name" field. I would like to display all features, but only label those features where NAME <> "". The same concept could be applied to roads, where TYPE = "Motorway".

In the image below, I want all polygons visible, but don't want to label the 3 polys on the right.

enter image description here

share|improve this question
up vote 4 down vote accepted

You can remove the text 'Label' from "Default Label" option in labeling dialog.

(Or use new labeling.)

There is no SQL for labels yet (but you don't need it in this case).

share|improve this answer
Well, that was pretty obvious solution for my immediate needs of removing the default "Label". Are there any plans for SQL based labeling in the future? And where can I find the "new labeling" you mentioned (I am using v1.6)? – RyanDalton Feb 17 '11 at 19:03
'Labeling' tool is located in 'Attributes toolbar' in 1.6 (icon reads 'ABC') – underdark Feb 17 '11 at 19:27
I couldn't find a ticket for this feature. You might want to file an enhancement request at – underdark Feb 17 '11 at 19:33

You can now label features using an expression in version 1.8, something like this:



CASE WHEN "TYPE" = 'Motorway' THEN "Name" END

Expression labels

share|improve this answer
Ignore the Expression is invaild that is because I don't have those columns in layer – Nathan W Jul 20 '12 at 3:39
That's a nice addition. Thanks. – RyanDalton Jul 20 '12 at 14:15

You can select the option in Labels Properties and only label 'selected features'

share|improve this answer
While that is a neat tool that can be used much like a "tool tip", it doesn't really work in my scenario because I don't want to label a selection set, but rather the whole data layer, just without certain characteristics. With "selected features" turned on, it will reset the labels with each change in the selection. – RyanDalton Feb 17 '11 at 19:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.