I'm using the field calculator to reclassify a raster table. My goal is to reclassify all negative values to zero, and keep all other original values. See attached photo.
I'm running the following block of code:
def Reclass(corrected_value):
if Value <= 0:
return 0
elif Value >= 1:
return Value
followed by:
Reclass( !corrected_value!)
Executing the code returns no errors, but values remain as NULL after processing. What gives?
Solved! Go to Solution.
def Reclass(value): if value <= 0: return 0 elif value >=1: return value
Reclass(!Value!)
But I suspect you really want to reclass the Value field
def Reclass(value): if value <= 0: return 0 elif value >=1: return value
Reclass(!Value!)
But I suspect you really want to reclass the Value field
Dan, thanks for your quick response. You're absolutely right, I need to reclassify a raster. Unfortunately the values are incorrect in the raster. For some reason there are some random values from -32000 to 0.
Can I reclassify all negative values as -1 and then have a raster values from 0-3460?
That value is your nodata value for an integer raster, I would just leave it alone. Since you aren't reclassifying the raster, but just reclassing values in a table, then just remember that and leave well enough alone
thanks for your patience Dan