hello, i want to calculate feild using phyton if function to do the following :
if Height_Delta is greater than 0 write in the status cell " Uprise"
if Height_Delta is less than 0 write in the status cell "Downrise"
image is attached
can anyone can help with the code ?
thanks.
Solved! Go to Solution.
["Down_rise", "Up_rise"][!Height_Delta! > 0]
goes under Status = line
not in the code block
some background
Fundamentals of field calculations—ArcGIS Pro | Documentation
Height_Delta = 5 # ---- example value
["Down_rise", "Up_rise"][Height_Delta > 0]
'Up_rise'
Remember to put ! marks around Height_Delta ( !Height_Delta! ) since it is a python field calculator expression
can u tell where to write each line of the code in the feild calculator window ?
image is attached here :
thank u
["Down_rise", "Up_rise"][!Height_Delta! > 0]
goes under Status = line
not in the code block
some background
Fundamentals of field calculations—ArcGIS Pro | Documentation
Another alternative.
Expression:
Slope(!Height_Delta!)
Code Block:
def Slope(HT):
if HT< 0:
return 'Downrise'
else:
return 'Uprise'
expression
code_block(!Height_Delta!)
code block
def code_block(fld)
"""code block isn't really needed"""
return ["Down_rise", "Up_rise"][fld > 0]
but as you can see it really isn't needed