Kappienl

Python in Field Calculator

Discussion created by Kappienl on Dec 13, 2012
Latest reply on Dec 13, 2012 by brucejr312
I'm using the python example named on http://resources.arcgis.com/en/help/main/10.1/index.html#/Calculate_Field_examples/005s0000002m000000/

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


But i want to use this with 4 categories. So a wellyield with value 8 and category 1 gets a 1 return but a wellyield with value 8 and category 2 gets a 5 return and so on...

For example:
def Reclass(WellYield):
  if (Category = 1 and WellYield >= 0 and WellYield <= 720):
    return 10
  elif (Category = 1 and WellYield > 721 and WellYield <= 1085):
    return 20
  elif (Category = 1 and WellYield > 1086 and WellYield <= 1450):
    return 30
  elif (Category = 1 and  WellYield > 1451):
    return 40

  if (Category = 2 and WellYield >= 0 and WellYield <= 720):
    return 20
  elif (Category = 2 and WellYield > 721 and WellYield <= 1085):
    return 30
  elif (Category = 2 and WellYield > 1086 and WellYield <= 1450):
    return 40
  elif (Category = 2 and WellYield > 1451):
    return 50

  if (Category = 3 and WellYield >= 0 and WellYield <= 720):
    return 30
  elif (Category = 3 and WellYield > 721 and WellYield <= 1085):
    return 40
  elif (Category = 3 and WellYield > 1086 and WellYield <= 1450):
    return 50
  elif (Category = 3 and WellYield > 1451):
    return 60

  if (Category = 4 and  WellYield >= 0 and WellYield <= 720):
    return 40
  elif (Category = 4 and  WellYield > 721 and WellYield <= 1085):
    return 50
  elif (Category = 4 and  WellYield > 1086 and WellYield <= 1450):
    return 60
  elif (Category = 4 and  WellYield > 1451):
    return 70


But of course this one doesnt work. How do i get it to work ?

Thx in advance

Outcomes