Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Field calculation - python newbie

$
0
0
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:
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

Viewing all articles
Browse latest Browse all 2485

Trending Articles