0

I am an experienced ArcMap user who is fairly new to Python. I am having trouble getting the script to look for a list of values and assign a new label in a new column. The script runs without errors but it does not fill in the new column.

Do the two columns need to be the same type?

I have provided the code that I use in the code block of the field calculator. In the other half of the field calculator I have

def reclass(Landing_Factor):
 if Landing_Factor >=1.0 and Landing_Factor <=1.99:
 return "A"
 elif Landing_Factor >= 2 and Landing_Factor <=2.99:
 return "B"
 elif Landing_Factor >= 3 and Landing_Factor <=3.99:
 return "C"
 elif Landing_Factor >= 4 and Landing_Factor <=4.99:
 return "D"
 elif Landing_Factor >= 5 and Landing_Factor <=5.99:
 return "E"
 elif Landing_Factor >= 6 and Landing_Factor <=6.99:
 return "F"
 elif Landing_Factor >= 7 and Landing_Factor <=7.99:
 return "G"
 elif Landing_Factor >= 8 and Landing_Factor <=8.99:
 return "H"
 elif Landing_Factor >= 9 and Landing_Factor <=9.99:
 return "I" 
 else:
 return "N/A"
BENCH_1 = TextValue( !BENCH_1! )
asked Aug 11, 2020 at 14:31
4
  • 2
    The function is named reclass. Where is TextValue defined? Note that your comparison operators leave room for 7.99000000001 to be encoded 'N/A' -- it is much safer to use '>=' and < together to prevent floating-point representation artifacts. Commented Aug 11, 2020 at 14:59
  • Was at the top of the script and i have placed it. That was an error on my part. I keep in mind using '>=' and < for the furture. Commented Aug 11, 2020 at 19:28
  • BENCH_1 = TextValue( !BENCH_1! ) doesn't make much sense in this context. If you want to calculate bench_2 = reclass( !BENCH_1!), that would make sense (where Bench_2 is a Text field of at least width 3). Note that, since you use early return directives, there is no difference between elif and if inside the function. Commented Aug 11, 2020 at 21:49
  • Have a look at gis.stackexchange.com/questions/177652/… it requires very little modification to achieve what you are after. Commented Aug 13, 2020 at 0:21

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.