In a shapefile, I have Field named Elevation with a text field containing integer ranges stored as strings:
1 - 2
3 - 6
2 - 3
8.5 - 12
11 - 12
I need to categorize it using rule that
if
Elevation < 1 then Index = 0.3 ,if Elevation = 2 - 3 Index = 0.6, if Elevation > 3 Index = 1
I use this code :
def Reclass( Elevation ):
r_min, r_max = (float(s.strip()) for s in Elevation.split('-'))
if r_min < 1 and r_max < 1:
return 0.333
elif r_min >= 1 and r_max >= 1 and r_min <= 3 and r_max <= 3:
return 0.666
elif r_min > 3 and r_max > 3:
return 1
elif r_min <= 3 and r_max > 3:
return 1
else:
return 999
error log :
General error executing calculator.
ERROR 999999: Error executing function.
Expected ')'
Failed to execute (CalculateField).
Failed at Mon Feb 10 10:31:00 2014 (Elapsed Time: 0,01 seconds)
Shape : https://drive.google.com/file/d/0BzTrGTReNp4mREk1UUEyYzh0TTA/edit?usp=sharing
If I run that code in python window it runs perfectly but gets error in field calculator. how to fix that code in field calculator based on error log?