Returning Original Value in Field Calculator Python Reclass

544
2
Jump to solution
01-05-2022 11:42 AM
ChrisSpadi
New Contributor III

I am reclassifying a integer field with the following code in field calculator:

Reclass(!Field!)

# Reclassify values to another value
# More calculator examples at esriurl.com/CalculatorExamples
def Reclass(arg):
if arg is None:
return None
elif arg <= 0:
return None
elif arg >= 1:
return 1
return arg

___________________________________________

For the last elif, I would like to return the original value being evaluated.  What do I need to replace 1 with in order to get the original value?

If I remove 'elif arg >= 1 and return 1', all the fields return None. Probably real simple but cant seem to find solution on any of the forums.

0 Kudos
1 Solution

Accepted Solutions
JayantaPoddar
MVP Esteemed Contributor

What if you remove just the following line from the codeblock?

 

return 1

 

or you could have the codeblock like

def Reclass(arg):
if arg >= 1:
return arg
else:
return None

 



Think Location

View solution in original post

2 Replies
JayantaPoddar
MVP Esteemed Contributor

What if you remove just the following line from the codeblock?

 

return 1

 

or you could have the codeblock like

def Reclass(arg):
if arg >= 1:
return arg
else:
return None

 



Think Location
ChrisSpadi
New Contributor III

Thanks.

0 Kudos