-1

I'm getting my feet wet with python in the field Calculator. I'm working with contour data and I'm looking to see if someone can help me.

I basically need to do this, but with python.

  • Links are fine to use as background to a question but should not form part of it. Potential answerers should not be expected to follow links to synthesize what it is that you want to ask. – PolyGeo Jul 15 '16 at 2:15
1

This works for me:

def setindex(height):
 dIndexInterval = 50
 dCont = height
 i = dCont / dIndexInterval
 if  ( dCont / dIndexInterval) - i == 0:
  return 1
 else:
  return 0

And then setindex( !ELEV! ) in the bottom window where ELEV is the name of your elevation field.

Edit The code given in the link looks buggy, as far as I can tell it will always return 1. The code below should work correctly if modulo is used instead to find the index contours.

def setindex(height):
 dIndexInterval = 50
 dCont = height
 if  dCont % dIndexInterval == 0:
  return 1
 else:
  return 0
  • Could something be wrong with the calculation. As it stands all the values are going to be 1. or am I Missing Something? – Jean Dekoz Jul 14 '16 at 21:31
  • I think something is wrong with the logic in the link you posted, from what i can see the returned value will always be 1. To be honest if I was looking for index contours I would use the modulo operation. something like "if dCont % dIndexInterval == 0" – Dowlers Jul 14 '16 at 21:48
  • That Works perfect. – Jean Dekoz Jul 14 '16 at 21:56

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