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

I have SHP layer loaded in QGIS. It consists of lines with attribute column z, containing integer value associated with line elevation in meters. Lines are drawn at 10 meter increment, and I want to apply style to lines on 50 meter increment.

For that purpose in "Style" tab in "Layer Properties" dialog, I use "rule based" style and want to define above described rule. From available operators I can see only one possibility with this filter expression:

z/50 - toint(z/50) = 0

However it returns true for all lines, while I expected just those with 50 meter increment.

There is also "Expression builder" dialog, but it does not return results from typed expression, for some reason, and I'm not able to determine what is the problem?

Any ideas?

share|improve this question

I'm not sure, as already mentioned expression output is not available, but I guess that expression evaluation is like in Python - if float number isn't used result is integer regardless real value. So this worked for me:

z/50.0 - toint(z/50.0) = 0

in lack of modulo operator

share|improve this answer
Mod is the symbol %. Yes the QGIS expression engine will return a int if both sides are ints, if one is a float it will return a float. – Nathan W Dec 2 '12 at 22:18

To get Index contours I use this on QGIS Field Calculator:

if(((round("level", 0) * 10) % (200 * 10)) = 0, 1, 0)

""level"" Set to contour height field "200" Set to interval of index contours

Then: "1" is an index contour and "0" is not an index contour

share|improve this answer

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.