Select to view content in your preferred language

Reclassifying Values in a Text Field

2511
2
09-28-2011 08:05 AM
TomKoritansky
Emerging Contributor
Hello all,

I am trying to reclassify a text field that was populated with values from a numeric field.  The numeric values represent riparian setback buffer widths, and I would like the reclassified values in the field that I am calling "SetbackType" to be more descriptive.  So instead of having a value of just "25" I would like the field value to contain the string "25 ft setback".

I found a block of code from the ArcGIS 10 help to reclassify a field, there are no errors in the code that prevent the script from running, but after it has run in the field calculator, the values for the "SetbackType" field have not changed.  Any thoughts on what the problem might be? 

Here is the code I am using.

def Reclass(SetbackType):
  if SetbackType == 25:
    return "25 ft Setback"
  elif SetbackType == 75:
    return "75 ftSetback"
  elif SetbackType == 120:
    return "120 ft Setback"
Tags (2)
0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor
Are you attempting to write the new text values to the same field or a new field?  I was able to get the code working when writing the values to a new field.  I have the 25, 75, 120 values in a field called 'Class' and then I created a new field called 'Description'. Next, I ran the following code:

Pre-logic Script Code:
def Reclass(SetbackType):
 if SetbackType == 25:
  return "25 ft Setback"
 elif SetbackType == 75:
  return "75 ft Setback"
 elif SetbackType == 120:
  return "120 ft Setback"


Description =
Reclass(!Class!)
0 Kudos
TomKoritansky
Emerging Contributor
Thanks for your help.  I tried using the code with your example and found my error.  Everything works as it should now!
0 Kudos