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!
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! )
Edit: I should mention I am using ESRI's ArcMap and Field Calculator for this task.
Try it from attribute table field calculator, mark check on Show Codeblock in attribute table Field Calculator
type this in the Pre-logic Script Code:
def pFunction(Direction,DirNB,DirSB):
if (Direction == "N") or (Direction == "E"):
return DirNB
elif (Direction == "W") or (Direction == "S"):
return DirSB
else:
return 00
and this in lower textbox
pFunction(!Direction!,!Dir__NB_or!,!Dir_SB_or!)