Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a Contours Featureclass, with an interval of 0.2 Meters. I wish to select only those Contours, which are which are at 1 m Interval?

I have tried using the following syntax in the 'Select by Attribute' dialog (in ArcMap, but it selects all the contours:

Mod("ELEVATION", 1)=0

What query should I run?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

The simple trick to select only Integer values, is to use the following syntax:

Mod(Round("ELEVATION", 0)*10, 10)=0

This Multiplication by 10, makes all the values Integer, and then we select only those which are multiples of 10.

In case you wish to select Multiples of some other number, just multiply 10 by the interval.

  • To get contours at 5 m intervals, use:

    Mod(Round("ELEVATION",0) * 10, 50)=0

  • To get contours at 100 m interval use:

    Mod(Round("ELEVATION", 0) * 10, 1000)=0

Update
As per Whuber's advice given in the comment below, I have added the rounding function in the query expression.

share|improve this answer
4  
I don't think I would trust these solutions. The problem is that with non-integral intervals of 0.2, the database is likely storing them as floats. Consequently MOD will be subject to floating-point roundoff error--and that's critical here: if you're low by even the very least significant digit, MOD may return the wrong value (depending on how it is implemented). I would like to suggest rounding the values before applying MOD as a way of preventing these subtle (and insidious) errors. –  whuber Apr 17 '13 at 16:08
    
You need to round after multiplying by 10, but before finding the mod. –  smithkm Aug 23 '13 at 15:59
    
If I want to select contours at 5m intervals, the formula implemented as-written above selects non-integers that round to a number that is evenly divisible by 5. E.g., 14.5m and 19.5m were selected but this is not desired. These were not selected if I dropped the 'Round' part of the function. –  delongtime Jan 6 at 17:50
    
@delongtime If you have contours that are supposed to have non-integral levels, simply modify the second argument of ROUND to achieve more precision in the rounding. –  whuber Jan 6 at 17:58

This was meant to be a comment on the above answer - sorry.

Syntax would vary depending on the type of DB your Contours are stored in but the given solution seems to pick contours after rounding their values. So for example in my test this achieved a selected set that included .3 m as well as .4 m. In fact, it excluded none of the values.

This equation

Mod(Round("ELEVATION" * 10, 0), 2)=0

Gave me results that seemed to match what the questioner was asking.

share|improve this answer

Your Answer

 
discard

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.