I have a shapefile of contour lines, with an ALTITUDE attribute with the height ASL in metres. The source data is in 0.5m intervals, but I'd like to filter it down so I get contour lines at (for eg.) 5m intervals.

I tried doing a query on the layer using "ALTITUDE" % 5 = 0, which almost worked except I get two contour lines where I would expect one - I'm guessing this is because % is an integer operation so 245.5 % 5 and 245.0 % 5 both = 0?

Is there a better way to filter for 5m (or some other interval, say 1m or 2.5m) data?

1 Answer 1


Multiply everything with 10 to get rid of your first decimal place:

("ALTITUDE"*10) % (5*10) = 0

This should work accordingly with any other figure.

  • 1
    I was just walking the dog and thought "Of course! I should just multiply everything by 10!"...and got home to find this. Thank you, good sir. :)
    – Juffy
    May 3, 2013 at 11:38
  • 1
    @Juffy Next time, my answer on a question of yours will be: "Go and walk the dog!" ;) Happy multiplying!
    – Bernd V.
    May 3, 2013 at 13:25
  • Walking the dog is right up there with Atwood's "Rubber duck problem solving" perhaps.
    – Simbamangu
    May 3, 2013 at 13:58
  • 1
    I'd prefer walking my dog over talking to a stupid rubber duck on my desk ...
    – Bernd V.
    May 3, 2013 at 15:01
  • But if the rubber duck knows the answer and you don't, is the duck really the stupid one? :)
    – Juffy
    May 7, 2013 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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