2011-03-11 15:00
Please read the updated version for QGIS 2.8 and up!
The aim of this post is to describe a method for labeling of a subset of features within a layer using new labeling functionality.
Often, we want to label only a few features in a layer. Of course we can export those features to a new layer and label them that way, but that requires creation of additional files and layers within your project. Things will start to get messy fast.
Another approach is to delete unwanted label texts from the attribute table. This either means that you have to duplicate a “name” attribute and then start deleting from the newly created attribute table column or that you actually delete values in the original column. Both approaches are problematic. Either you produce redundancy that gets difficult to maintain (two attributes have to be updated if the name of a feature changes) or you loose information from the attribute table.
Let me present a different approach using new labeling tools. The idea is based on moving unwanted labels out of view. This approach avoids duplication of features and duplication/deletion of label texts. And this is the workflow:
If you change your mind about a feature and want to label it later on: Simply delete the values in “label_x” and “label_y” fields (so they read NULL).
This works quite well for me but I’m aware that it’s still not optimal. Another “data defined setting” like “show this label (true/false)” would be more intuitive.
Have you found better solutions to this problem? Please, post them!
Posted by underdark
Mobile Site | Full Site
Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.
– Right-click a vector layer, choose Properties
– Choose “Labels” on the left hand side
– Choose tab “Label Properties” on the right hand side
– On the top panel “Basic Label Options”: check “Label only selected features”.
Done!
By Stephan van den Akker on 2011-03-11 at 16:44
Hi Stephan,
You’re right, this works perfectly fine with old style labeling but not with the newer more flexible one.
Thanks for posting!
By underdark on 2011-03-11 at 20:57
Hello,
I’m using similar method, but insted X,Y value I’m setting font size to zero.
Great blog!
Cheers
By Piotr Pociask on 2011-03-12 at 14:27
Hi Piotr,
That works great too. Thank you!
By underdark on 2011-03-12 at 15:48