mardi 31 juillet 2018

Reclassifying an "Add Field" with If/Else statement based on multiple fields

Like a lot of people here I was tasked with a project many have given up on because I took one Python course during my college term.

Anyways, my delima does not seem so difficult, I am just too new to Python to figure it out myself. Here goes:

I have a table of Traffic Count data with: Street Location | Direction | Dir__NB_or | Dir_SB_or and I was attempting to write a reclassification into the new field of Count.

What I am looking for is a script to say: "if direction is N or E, insert Dir__NB_or into field Count"

Is what I have, (probably horrific) but I would appreciate any help you can provide!

Alex

Reclass (Dir__NB_or , Dir_SB_or, Direction):

    if (Direction == "N"):
           return Dir__NB_or
    elif (Direction == "S"):
            return Dir_SB_or
    elif (Direction == "E"):
            return Dir__NB_or
    elif (Direction == "W"):
            return Dir_SB_or
    else:
            return "0000"

Count =

Reclass ( !Dir__NB_or! , !Dir_SB_or!, !Direction! )

Aucun commentaire:

Enregistrer un commentaire