Select to view content in your preferred language

Field classification using field calculator and python script

1189
2
08-29-2012 02:44 PM
SamNeale
Deactivated User
Hi I'm trying to classify a field based on a land classification value in a different field.  I've searched around the forums, but haven't had any success building a working script. 

Pre-logic Script Code:
def Reclass( !LUCode!):
  if ( !LU_2005! = "AG")
    return "Pasture"
  if ( !LU_2005! = "ST")
    return "Urban" 


LUCode =
Reclass( !LUCODE!)

Any help would be greatly appreciated.

Thanks.
Tags (2)
0 Kudos
2 Replies
JasonScheirer
Esri Alum
Expression:

Reclass(!LUCode!, !LU_2005!)

Codeblock:

def Reclass(LUCode, LU_2005):
  if LU_2005 == "AG":
    return "Pasture"
  elif LU_2005! == "ST":
    return "Urban"
  else:
    return "???"



Python uses == for equality, and you can't use !Field!s in the codeblock.
0 Kudos
SamNeale
Deactivated User
Great, thank you!
0 Kudos