Select to view content in your preferred language

ArcGIS Pro 2.8.4: The Python If statement fails to work,

652
3
Jump to solution
06-27-2022 10:10 AM
JamalNUMAN
Legendary Contributor

ArcGIS Pro 2.8.4: The Python If statement fails to work,

 

In the screenshot below, I wanted to apply a simple if statement but fails to work and ends up with an error

 

-----

def Reclass(Confinement):

    if Confinement == Confined:

        return 1500

 

    return 0

-----

 

What could be the issue here?

 

The data is attached

 

 

Clip_784.jpgClip_785.jpg

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
1 Solution

Accepted Solutions
JayantaPoddar
MVP Alum

Code Block:

def Reclass(Confinement):
    if Confinement == 'Confined':
        return 1500
    else:
        return 0

 



Think Location

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

 Confinement == "Confined"

and it should be, with a python parser

Reclass(!Confinement!)

to invoke it.  Note the enclosing ! marks


... sort of retired...
JayantaPoddar
MVP Alum

Code Block:

def Reclass(Confinement):
    if Confinement == 'Confined':
        return 1500
    else:
        return 0

 



Think Location
JamalNUMAN
Legendary Contributor

Thank you JayantaPoddar for the help. It works fine

 

------

def Reclass(Confinement):

    if Confinement == 'Confined':

        return 1500

    else:

        return 0

--------

 

 

Clip_786.jpg

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos