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 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?

share|improve this question
    
There is a mistake in the Expression; it should read: Expression: Reclass(!WELLYIELD!) NOT Reclass(!WELLYIELD!) –  user28883 Apr 6 at 7:04

1 Answer 1

up vote 4 down vote accepted

This is a Job for the Field Calculator.

See this Python example at Calculate Field examples

Parser:
Python

Expression:
Reclass(!WELL_YIELD!)

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
share|improve this answer
3  
Are you aware that Python has an int() function built in? Consider what the expression 1 + int((WellYield-1) / 10) will do. –  whuber Apr 15 '12 at 14:23
    
@whuber: I was aware of the int() function, but hadn't thought of using it this way. –  Devdatta Tengshe Apr 15 '12 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 Apr 15 '12 at 14:32

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.