4

How would I go about labeling every other feature in QGIS (1.8)?

For example I have a set of contours every 10 meters from 0m to 100m. How would I label only every 20 meter contour? e.g. label contours 0, 20, 40, 60, 80 and 100m while showing all the contours.

  • 2
    In ArcGIS, I have used a mod() query to select the contours I wanted to label, and then labeled only the selected features. This should be possible in QGIS too. Syntax for the query should be something like mod('elev',20)=0 where 'elev' is the contour value. – L_Holcombe Feb 26 '13 at 6:23
5

Use the following modulo expression to filter your labels :

"Z" % 20 = 0

You can use rule based labeling :

modulo labelling

Or to give you a useful example, below :

I duplicated my contour layer and filtered the duplicated layer to be able to apply labeling + add a bold style at the same time only on 0/20/40/60/80/100 lines without using any other rules.

filter and modulo

1

According to the question

I think following steps will be helpful for you..

1.Select the features you want to label

2.Open attribute table

3.If you don’t have label attributes ready yet: Add two type “real” columns called e.g. “label_x” and “label_y”

4.Invert the selection (3rd button in attribute table window)

5.Open field calculator and fill “label_x” and “label_y” fields of the selected features with 0 values (or any coordinates outside your map extent)

6.Close field calculator and attribute table

7.Save your edits

8.Open the labeling dialog and set “data defined settings” – “x coordinate” and “y coordinate”

9.Enable “Label this layer” and specify the label field

10.Done

For details please visit our admin (@Underdark) blog

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.