AnsweredAssumed Answered

polygon vertex angle arcpy

Question asked by bayojugger on Feb 21, 2020
Latest reply on Feb 24, 2020 by bayojugger

The goal is to find the angle at each vertex. My current computation which started with the clue I got here, isn't giving me the expected vertex angle values. By expected values, I mean angles at vertex measured using ArcMap10 COGO tool.

inFC (input feature class) are polylines which were a result of polygon split operation.

I am also not getting it right with regards to pushing those angle values to the field "Angle"

Alternate approaches are welcome.

 

# get the vertex angle
def getVertexAngle(inFC):

    arcpy.AddField_management(inFC,"Angle","DOUBLE")

    pointer = 0

    with arcpy.da.UpdateCursor(inFC, 'Angle') as uCur:
        with arcpy.da.SearchCursor(inFC, 'SHAPE@') as sCur:
            for row in sCur:
                orient = []

                Geom = row[0]
                Parts = range(Geom.partCount)

                for part in Parts:
                    currPart = Geom.getPart(part)
                    pointCount = currPart.count

                    qPointsRange = range(1, pointCount - 1)

                    for point in qPointsRange:
                        currPnt = currPart.getObject(point)
                        X = currPnt.X
                        Y = currPnt.Y

                        prevPnt = currPart.getObject(point - 1)
                        nxtPnt = currPart.getObject(point + 1)

                        radian = math.atan2(Y - prevPnt.Y, X - prevPnt.X) - math.atan2(nxtPnt.Y - prevPnt.Y, nxtPnt.X - prevPnt.X)

                        degrees = 90 - math.degrees ( math.radians( radian ) )
                        orient.append(degrees)

                        print degrees

    print "orientations are: ", orient
    return orient

Outcomes