Field calculator

415
2
Jump to solution
03-12-2022 12:49 PM
FOUADHAMDAN_SAAD
New Contributor II

Hi community.... 

I tried to applied field calculation using Python in field type "text" as show below:

Expression:

reclass (!code!)

code block:

def reclass(code):
if (code =13):
return "Industrial"
elif (code = 16):
return "Urban or Built-up Land"
elif (code = 0):
return "Unclassified"

I got an error, please I need your help. 

Thank you in advance.

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

python parser

def reclass(code):
    if code == 13:
        return "Industrial"
    elif code == 16:
        return "Urban or Built-up Land"
    elif code == 0:
        return "Unclassified"

equality check is ==

assignment is =

Error message would be useful in case this doesn't cover it.


... sort of retired...

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

python parser

def reclass(code):
    if code == 13:
        return "Industrial"
    elif code == 16:
        return "Urban or Built-up Land"
    elif code == 0:
        return "Unclassified"

equality check is ==

assignment is =

Error message would be useful in case this doesn't cover it.


... sort of retired...
0 Kudos
FOUADHAMDAN_SAAD
New Contributor II

Thank you @DanPatterson , I appreciate you. 

0 Kudos