Field calculator returns null fields?

3057
4
Jump to solution
01-02-2016 05:23 AM
ShelbyZemken1
New Contributor III

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?code_block.PNG

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Esteemed Contributor
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

View solution in original post

4 Replies
DanPatterson_Retired
MVP Esteemed Contributor
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

ShelbyZemken1
New Contributor III

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?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

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

ShelbyZemken1
New Contributor III

thanks for your patience Dan

0 Kudos