Calculate Field (Multiple) tool not working when using two different expressions in the code block

569
3
07-21-2020 10:38 AM
JenniferLawrie
New Contributor

Hi,

Looking for help using the Calculate Fields (Multiple) tool. Individually I am able to calculate my two fields successfully. However, when I use the multiple tool, and put both expressions into the code block, it skips the first def Reclass and only carries out the second? I feel like this should be easy to resolve, but cannot work out what i am doing wrong!

I have attached a screen grab of the tool dialogue box and have included the code block below.....

def Reclass(Surface):
    if Surface is None:
        return 0
    elif Surface == "Well Drained":
        return 0.5
    elif Surface == "Boggy":
        return 1
    elif Surface == "Standing Water":
        return 1.5
    elif Surface == "Blocked Drainage":
        return 3  
def Reclass(Evidence_of_Instability):
    if Evidence_of_Instability is "None":
        return 1
    elif Evidence_of_Instability == "Surface Erosion":
        return 1.4
    elif Evidence_of_Instability == "Localised Evidence":
        return 1.7
    elif Evidence_of_Instability == "Extensive Evidence":
        return 2 

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Try renaming one of the def's to Reclass2.  I suspect the duplicate function name is why you are getting only the last one


... sort of retired...
JenniferLawrie
New Contributor

Hi Dan,

Thanks for this, it has worked Still fairly new to model builder/python and assumed that because each Reclass function was followed by a different field, it would carry out both. This does make sense though, so thanks!

0 Kudos
DanPatterson
MVP Esteemed Contributor

no problem


... sort of retired...
0 Kudos