0

I have a table as like below:

enter image description here

I want to generate python script to calculate the value Low, Medium and High into a single layer.

I tried using this script:

Parser:
Python

Expression:
Reclass( Flood_Severity )

Code Block:
def Reclass ( Flood_Severity ):
    if ( FAT = 1 and FV = 1 and FD < 3):
        return "Low"
    elif ( FAT = 1 and FV = 1 and FD >= 3):
        return "Medium"
    elif ( FAT = 1 and FV = 2 and FD = 1):
        return "Low"
    elif ( FAT = 1 and FV = 2 and FD > 1 and FD < 4):
        return "Medium"
    elif ( FAT = 1 and FV = 2 and FD=4):
        return "High"

But it failed. May I know how to fix the script?

3
  • 2
    Failed how? Do you get errors? Your table cant look like that in ArcMap, can you add a screenshot showing the attribute table
    – Bera
    Commented Oct 4, 2021 at 8:22
  • I agree with @BERA you need to edit your question and include an image of your data as it is in ArcMap.
    – Hornbydd
    Commented Oct 4, 2021 at 13:18
  • Table shown cannot be analyzed. It looks like result of normal flat database table pivoted in Excel or similar.
    – FelixIP
    Commented Oct 4, 2021 at 18:40

1 Answer 1

3

You are going to get errors for using = as a comparison operator , it should be two ==.

See: Python Operators

And you need to include all the fields you use in the function, when declaring and calling it:

def Reclass ( FAT, FV, FD ):
   ...

And when you call it:

Reclass( !FAT!, !FV!, !FD! )

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.