AnsweredAssumed Answered

Writing script to add to toolbox

Question asked by John_T on Jul 19, 2012
Latest reply on Jul 23, 2012 by John_T
Hi,

I wrote the following to reclassify polyline slope values in a new field with field calculator.

def Slope(Avg_Slope):
if ( "Avg_Slope" >= 0 and  "Avg_Slope" <= 2):
  return 1
elif ( "Avg_Slope" > 2 and  "Avg_Slope" <= 3):
  return 1.2
elif ( "Avg_Slope" > 3 and  "Avg_Slope" <= 4):
  return 1.3
elif ( "Avg_Slope" > 4 and  "Avg_Slope" <= 5):
  return 1.4
elif ( "Avg_Slope" > 5 and  "Avg_Slope" <= 6):
  return 1.5
elif ( "Avg_Slope" > 6 and  "Avg_Slope" <= 7):
  return 1.6
elif ( "Avg_Slope" > 7 and  "Avg_Slope" <= 8):
  return 1.75 
else:
  return 2

This works fine. What I need to do now is write this in a  script which i can add to a toolbox. As a python novice this is proving beyond me.

So far I've imported arcpy and set my work environment but I don't know what to do next.

Any help would be greatly appreciated.

John

Outcomes