Use Modulus to Identify Layers Divisible by a Number
Identifying the 10 foot contour lines is accomplished using the modulus operator. Modulus calculates the remainder of one number divided by another. If the remainder is zero, the first number is divisible by the second.
SQL supports modulus, but definition queries in ArcGIS do not support full SQL. A quick test discovered modulus falls into the unsupported category. Therefore, the solution is to create a new field and calculate the field using the modulus operator to identify the layers to display.
With the new field created, now it is time to calculate the field. This field will be used to note whether the feature is a contour divisible by 10 (60, 80, 90, etc) or not. What we are creating is a true or false field to indicate this. Why did we make it an integer you ask? It is because of the way the computer views boolean (true/false) values. To the computer, zero is false and one (or any other value of that matter) is true. We are going to take advantage of this when we use the field calculator.
Open up the field calculator by right clicking on the new field header and selecting Field Calculator from the context menu. In this instance, the contour field is storing the elevation I am interested in, so I need to determine if contour is divisible by 10. Since I use Python most of the time, this is the language I will be using. Hence, the first step is to select the Python radio button at the top of the dialog to select the parser.
The next step is entering the code to calculate the field. The modulus operator is the percent sign (%). Using the modulus operator, it will look like this.
This is literally telling ArcGIS to use Python to evaluate the following statement. Is the contour value modulus 10 equal to zero. In slightly more intelligible English, this translates to is the remainder zero when dividing the contour value by 10?
If the value is divisible by zero, it will return true. Since it is a computer, the computer returns a one to indicate true. If the value is not divisible by 10, it returns false. Again, since it is a computer, it will return a zero. To change this statement for another value, simply replace 10 with another number.