# Rule based styling of elevation lines

For elevation lines, I would like to have a different style of

• full: 1 m

• half: 0.5 m

• quarter: 0.25 and 0.75 m

lines. Manually, I managed to extract the different lines with the following via field calculator in the attibute table:

1. Extract 1 m values: if( "ELEV" = floor( "ELEV" ),"ELEV", '')
2. Extract 25, 50 and 75 cm values (name: “no1m”): if( "ELEV" = floor( "ELEV" ),'', "ELEV" )
3. Exctract 50 cm values: if( ("no1m" - 0.5) = floor( "no1m" ), "no1m",'')
4. Extract 0.25 and 0.75 values: if( ("no1m" - 0.5) = floor( "no1m" ),'',"no1m")

Now that I have that problem more frequently so I want to setup a QGIS layer style file to fasten the process of styling and labelling the elevation lines.

For the labels, it works to label the full lines by setting up the rule [if( "ELEV" = floor( "ELEV" ),"ELEV", '')] and for the half and quarter lines, I use a rule without filter but with label [if( "ELEV" = floor( "ELEV" ), '',"ELEV")]. Since I just want the 1 m labels to be larger, it is ok like that.

Now for the style, I can extract all 1 m lines with [if( "ELEV" = floor( "ELEV" ),"ELEV", '')] but as soon as I set a rule for the half m lines [if( "ELEV" = floor( "ELEV" ), '',"ELEV")], I dont see any lines. If I only click on one of the two labels, I can see it but together they seem to overrule each other and nothing is shown. How can this be solved? Also, how do I style the quarter lines in the rule based styling?

## 1 Answer

How about these rules?

``````Full lines:       ("ELEV" / 0.25) % 4 = 0
Half lines:       ("ELEV" / 0.25) % 4 = 2
Quarter lines:    ("ELEV" / 0.25) % 4 = 1 OR ("ELEV" / 0.25) % 4 = 3
``````