I have a table as like below:
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?
-
2Failed how? Do you get errors? Your table cant look like that in ArcMap, can you add a screenshot showing the attribute tableBera– Bera2021年10月04日 08:22:15 +00:00Commented 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– Hornbydd2021年10月04日 13:18:22 +00:00Commented 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– FelixIP2021年10月04日 18:40:54 +00:00Commented Oct 4, 2021 at 18:40
1 Answer 1
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! )
Explore related questions
See similar questions with these tags.