AnsweredAssumed Answered

Calculating angles of lines using pyscripting

Question asked by GoldenJiang on Sep 14, 2016
Latest reply on Sep 15, 2016 by Dan_Patterson

I am trying to put together a tool for calculating the angles of lines but I keep getting this error: "Parameters are not valid. ERROR000735".  I am new learning arcpy, can anyone tell me what have I done wrong here? 

import arcpy
import math
in_table = arcpy.GetParameterAsText(0)
field = arcpy.GetParameterAsText(1)
arcpy.AddField_management(in_table, "angle", "DOUBLE")
expression = "GetAzimuthPolyline(!shape!)"
codeblock = """def GetAzimuthPolyline(shape):
radian = math.atan((shape.lastpoint.y - shape.firstpoint.y)
/(shape.lastpoint.x - shape.firstpoint.x))
degrees = radian * 180/math.pi
return degrees"""