I am trying to populate a field with a L/R bank designation based on a route measure (as part of a larger script), but I am struggling. I have a shapefile created (tir_pts_lyr), I have a blank column (L_R_Bank), I have the measure value column (M_off_str). So if the measure value is negative, I want "L_R_Bank" to be populated with an "L", if the measure is positive, an "R", and if zero, a "C".
I'm trying to use the sample codeblocks in the ArcHelp, but they are lacking in detail for my knowledge level. I have no clue what to put in the expression field for getClass and how the next codeblock line relates to that. Any hints for a newbie.
#calc left/right bank using M-distance measure
# Set local variables
inTable = "tir_pts_lyr"
fieldName = "L_R_Bank"
expression = "getClass(float(!SHAPE.M_Off_str!))"
codeblock = """def getClass(M_Off_str):
if M_Off_str < 0:
return "L"
if M_Off_str > 0:
return "R"
else:
return "C" """
#Execute CalculateField
arcpy.CalculateField_management(inTable, fieldName, expression, "PYTHON", codeblock)