AnsweredAssumed Answered

Field calculation - python newbie

Question asked by mattowen on Feb 25, 2013
Latest reply on Feb 25, 2013 by mattowen
Hiya,

Wondering if anyone can help with this - I'm trying to reclassify a field. I've never used python before and have attempted a script which isn't working.

There are three fields (all floating point integers):
FIA_Th_m
FIB_Th_m
FIIA_Th_m

I need any negative values in FIIA_Th_m to be reclassified to 0.

This is what I've tried:

Expression:
Reclass(!FIIA_Th_m!, !FIA_Th_m!, !FIB_Th_m!)

Code:
def Reclass(FIIA_Th_m, FIA_Th_m, FIB_Th_m):   if FIIA_Th_m <= 0:     return 0   if FIIA_Th_m > 0:     return calc(FIIA - (FIA_Th_m + FIB_Th_m))


The error I got on the last attempt was 'Cannot acquire a lock'. I'm relatively confident with lines 1-4 of the code, but line 5 I sort of guessed as I don't know how to incorporate the mathematical function into the return.

Any advice much appreciated.

Cheers,

Matt

Outcomes