I'm trying to compare two fields to each other and then use that information to update a third field. Here are the fields that I have in my data:
Field A: Direction (numeric)
Field B: Bearing (numeric)
Field C: KeepDiscardFlag (text)
Below is the code that I've tried based on other discussions in GeoNet, but it doesn't work (errors out saying that it couldn't evaluate the python expression). What I'm trying to do is this:
- Make sure that Direction and Bearing are not null
- Set the KeepDiscardFlag field to "Keep" if Bearing is between Direction (plus or minus 22.5), or
- Set the KeepDiscardFlag field to "Delete" if Bearing is not between Direction (plus or minus 22.5)
Expression
Reclass(!KeepDiscardFlag!, !Direction!, !Bearing!)
Code Block
def Reclass(KeepDiscardFlag, Direction, Bearing):
if ( (Direction is None or Bearing is None) and (Direction - 22.5) <= Bearing <= (Direction + 22.5) 😞
KeepDiscardFlag = "Keep"
elif ( (Direction is None or Bearing is None) or (Direction - 22.5) >= Bearing >= (Direction + 22.5) 😞
KeepDiscardFlag = "Delete"
Any help would be greatly appreciated!