I would like to be able to take all values between 1 and 10 and have a field define them as 1, and all values between 10 and 20 and set them to 2, how do I do that with vector data?

I read how to set all building to 20, and grass to 40, but I'm pretty sure that to do that for a range of values, like 1-10, I would have to manually enter each number, and decimal in that range. Am I wrong? and if not, how would I accomplish this?

  • There is a mistake in the Expression; it should read: Expression: Reclass(!WELLYIELD!) NOT Reclass(!WELLYIELD!)
    – user28883
    Commented Apr 6, 2014 at 7:04

1 Answer 1


This is a Job for the Field Calculator.

See this Python example at Calculate Field examples



Code Block:
def Reclass(WellYield):
  if (WellYield >= 0 and WellYield <= 10):
    return 1
  elif (WellYield > 10 and WellYield <= 20):
    return 2
  elif (WellYield > 20 and WellYield <= 30):
    return 3
  elif (WellYield > 30):
    return 4
  • 3
    Are you aware that Python has an int() function built in? Consider what the expression 1 + int((WellYield-1) / 10) will do.
    – whuber
    Commented Apr 15, 2012 at 14:23
  • @whuber: I was aware of the int() function, but hadn't thought of using it this way. Commented Apr 15, 2012 at 14:26
  • 6
    That's why I pointed it out :-). Int() and its relatives, such as floor(), ceiling(), round(), and integer division, are the workhorses of reclassification because they are step functions: they attain a constant value over an interval and then jump to another value. (Their graphs in Cartesian coordinates look like stairsteps in profile.) Whenever you find yourself coding multiple if statements (in any language) to reclassify numerical values, think about using int() et al. to simplify the work (and speed the computation).
    – whuber
    Commented Apr 15, 2012 at 14:32

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.