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

what is the python expression for defining a range of numbers?

I have tried numerous combinations but cannot get a simple range of angles (100 -200) to compute correctly.

Screen shot :

Range in Field Calculator needed

share|improve this question
up vote 6 down vote accepted
if !ET_Angle! > 100 and !ET_Angle! < 200

To be more complete, put this in the codeblock:

def LeftOrRight(value):
    if value > 100 and value < 200:
         return "LEFT"
         return "RIGHT"

And in the calculation area, just put:

share|improve this answer
So many people ignore the codeblock. It can be very powerful. – Radar Jun 15 '11 at 18:13
I think they ignore it because the term "code" is rather intimidating unless you are familiar with the language. – Nathanus Jun 15 '11 at 18:23
Awesome! That's just what we needed! Much Thanks!! – sirgeo Jun 15 '11 at 19:53
You got it. Sometimes a few examples can make things clearer. – Nathanus Jun 15 '11 at 20:17
i always save these code solutions and i tried using previously saved codeblocks for this today, but needed further schooling on formulating range expressions... not really intimidated by python just exacerbated sometimes due to time constraints and lack of Google-Fu when looking for the answers... GSE is always a great help for filling in the gaps with Google-Fu . – sirgeo Jun 15 '11 at 21:57

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.