<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate Polygon Angles at Vertices in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534657#M41882</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Peter,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you ever get that script to work on a whole data set?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Mar 2013 13:11:39 GMT</pubDate>
    <dc:creator>MarkMenzel</dc:creator>
    <dc:date>2013-03-14T13:11:39Z</dc:date>
    <item>
      <title>Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534651#M41876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When I started this job someone had already had a contractor survey a bunch of our buildings at our installations and look at our cad drawings to make building footprints for real property management purposes.&amp;nbsp; I've been aligning floorplans to the these footprints, and much to my chagrin I find that a lot of these buildings that were entered are not square (apparently they thought maybe we buildt structures with 95° angles, needless to say we don't).&amp;nbsp; So now I'm writing a script to go through and calculate the angles at each vertex of the polygon so we can find out which buildings need to be resurveyed.&amp;nbsp; Right now I have the script so that it will calculate the vector of each line from the X axis.&amp;nbsp; But, what I need it to do is select the lines that interesect the vertex (the polygons are converted to polylines and then exploded, and points are created at the vertices) and I think I have that part down, but now I need to add the selected two lines vectors together to get the angle and put it in the field for angles at that vertex.&amp;nbsp; I then need to step through the process for each of the thousand some vertices with either a for or while loop.&amp;nbsp; I'm new to python but I think I can figure out the loop, but doing the math with the selected features is confusing me (actually any help with the loop would be nice too).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance, here's the code I have.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
#
# This Script Validates if the surveyed building footprints are square enough to be acceptable#
#
#

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Import system modules
import arcpy
import math
from arcpy import env

# Set environment settings
arcpy.env.workspace = "C:\Users\peter.a.metzger\Desktop\Projects\CGN_Building_survey_validating\Building_Validate.gdb"
inFeatures = "Building_footprint"

#Turn Polygon into Polyline in scratch workspace
arcpy.PolygonToLine_management (inFeatures, "polygon2polyline")

#explode polyline into individual lines
arcpy.SplitLine_management ("polygon2polyline",&amp;nbsp; "explodedLine")

#convert polygon vertices to points
arcpy.FeatureVerticesToPoints_management (inFeatures, "Poly2Point")


# Set local variables

fieldName = "Angle"
expression = "GetAzimuthPolyline(!Shape!)"
codeblock = """def GetAzimuthPolyline(shape):
&amp;nbsp;&amp;nbsp;&amp;nbsp; radian = math.atan((shape.lastpoint.x - shape.firstpoint.x)/(shape.lastpoint.y - shape.firstpoint.y))
&amp;nbsp;&amp;nbsp;&amp;nbsp; degrees = radian * 180 / math.pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; return degrees"""

# Execute AddField
arcpy.AddField_management("explodedLine", fieldName, "Double", 6)
arcpy.AddField_management("Poly2Point", fieldName, "Double", 6)

# Execute CalculateField 
arcpy.CalculateField_management("explodedLine", fieldName, expression, "PYTHON_9.3", codeblock)

# Make Poly2Point and explodedLine a layer file so that select by attribute can read it

arcpy.MakeFeatureLayer_management("Poly2Point", "Poly2Point_lyr")

arcpy.MakeFeatureLayer_management("explodedLine", "explodedLine_lyr")

#Step through each OBJECTID and select the polygons that share the point and subtract their values
##Select the vertex for the angle##

#NEED TO CHANGE TO A FOR LOOP#
#THIS IS WHERE I'M STUCK#
#NEED TO BE ABLE TO SUBTRACT THE TWO SELECTED LINES FROM ONE ANOTHER#
obid=1
arcpy.SelectLayerByAttribute_management ("Poly2Point_lyr", "NEW_SELECTION", "[OBJECTID] = 'obid'")

#select the two exploded lines from which to calculate the vertex angle

arcpy.SelectLayerByLocation_management ("explodedLine_lyr", "INTERSECT","Poly2Point_lyr", "", "NEW_SELECTION")
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 16:38:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534651#M41876</guid>
      <dc:creator>PeterMetzger1</dc:creator>
      <dc:date>2012-07-11T16:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534652#M41877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could get all the verticies in a building, and cycle through them, one at a time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Use Near_analysis (in_features, near_features, "", "", ANGLE)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;on each (as in_features) and the vertex before and vertex after it as near_features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Setting the {angle} parameter to ANGLE reports the angle....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can get the verticies as an array of points from the shape object.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 18:13:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534652#M41877</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-07-11T18:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534653#M41878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the input, I thought that would work and would be much simpler, I would just tell it to find the angle between the point and the closest point and then find the angle between the point and then the second closest point.&amp;nbsp; However, a lot of our buildings are not rectangular and have a lot of things jutting out.&amp;nbsp; Take for example in the image, I want to find the angle of Vertex A.&amp;nbsp; It would be done using near to find the angle to point C from A, and B from A.&amp;nbsp; The problem is that D is closer to A and would calculate the wrong angle.[ATTACH=CONFIG]15973[/ATTACH].&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For anyone else reading this post to clarify I am looking to solve for angle C in the following drawing, I have been able to calculate A and B&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [ATTACH=CONFIG]15974[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS sorry about the MS Paint images&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 19:01:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534653#M41878</guid>
      <dc:creator>PeterMetzger1</dc:creator>
      <dc:date>2012-07-11T19:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534654#M41879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Once you have A and B isn't C = 180-(A+B)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jul 2012 20:56:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534654#M41879</guid>
      <dc:creator>SolomonPulapkura</dc:creator>
      <dc:date>2012-07-11T20:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534655#M41880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I suggested cycling through the array of polygon points, not just getting angles to the closest two points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The array will have each vertex point in order, running clockwise for an exterior ring and counter-clockwise for an internal ring.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;See the page on Reading geometries for more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As well, unlike your diagram, the angles to nearest points 1 and 2 would be overlapping angles, not supplemental.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Both are measured from the x axis (east).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It would be the difference between the first and second angles you were looking to find.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Figuring if your calculated angle was internal or external is another issue, but if you are just flagging non-square corners, internal or external would not matter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Jul 2012 11:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534655#M41880</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-07-12T11:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534656#M41881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I went to the UC last week and had a very nice girl (Thanks Stephanie!) give me a hand on this, and we (mostly she) figured out how to get the angle at the vertices.&amp;nbsp; After the two lines at the vertex are selected the are exported to a feature class in memory and then a search cursor is used to get their angles, which are then put into a list and then subtracted from one another.&amp;nbsp; They are then put back into the layer file using an UpdateCursor.&amp;nbsp; This all worked great... when I was doing it on one vertex.&amp;nbsp; Once I tried to put it into a loop I keep getting an "IndexError: list index out of range".&amp;nbsp; Any help on what I have done wrong would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#
#
# This Script Validates if the surveyed building footprints are square enough to be acceptable#
#
#

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Import system modules
import arcpy
import math
from arcpy import env

# Set environment settings

arcpy.env.workspace = "in_memory"

inFeatures = "C:/Users/xxxxxxxx/Desktop/Projects/CGN_Building_survey_validating/test.gdb/test_footprint"

#Turn Polygon into Polyline in scratch workspace
arcpy.PolygonToLine_management (inFeatures, "polygon2polyline")

#explode polyline into individual lines
arcpy.SplitLine_management ("polygon2polyline",&amp;nbsp; "explodedLine")

#convert polygon vertices to points
arcpy.FeatureVerticesToPoints_management (inFeatures, "Poly2Point")


# Set local variables

fieldName = "Angle"
expression = "GetAzimuthPolyline(!Shape!)"
codeblock = """def GetAzimuthPolyline(shape):
&amp;nbsp;&amp;nbsp;&amp;nbsp; radian = math.atan((shape.lastpoint.x - shape.firstpoint.x)/(shape.lastpoint.y - shape.firstpoint.y))
&amp;nbsp;&amp;nbsp;&amp;nbsp; degrees = radian * 180 / math.pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; return degrees"""

# Execute AddField
arcpy.AddField_management("explodedLine", fieldName, "Double", 6)
arcpy.AddField_management("Poly2Point", fieldName, "Double", 6)

# Execute CalculateField 
arcpy.CalculateField_management("explodedLine", fieldName, expression, "PYTHON_9.3", codeblock)

# Make Poly2Point and explodedLine a layer file so that select by attribute can read it

arcpy.MakeFeatureLayer_management("Poly2Point", "Poly2Point_lyr")

arcpy.MakeFeatureLayer_management("explodedLine", "explodedLine_lyr")


#Identify how many vertices need to be calculated

numb_vertices = int(arcpy.GetCount_management("Poly2Point_lyr").getOutput(0)) 
print numb_vertices

#Loop through each vertex by OBJECTID

for i in range (0, numb_vertices):
&amp;nbsp;&amp;nbsp;&amp;nbsp; obj = "OBJECTID=%s" %(i)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management ("Poly2Point_lyr", "NEW_SELECTION", obj)

#select the two exploded lines from which to calculate the vertex angle

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management ("explodedLine_lyr", "INTERSECT","Poly2Point_lyr", "", "NEW_SELECTION")

#Export those lines to a new feature class

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion ("explodedLine_lyr", "in_memory", "calc_values")

#Create List to do angle math

&amp;nbsp;&amp;nbsp;&amp;nbsp; Angle_math = []

#Return Angle_Values

&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor ("calc_values","","","Angle")

&amp;nbsp;&amp;nbsp;&amp;nbsp; current_Angle_Object = ""

#Iterate through the rows in the cursor and add them to the list

&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if current_Angle_Object !=row.Angle:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; current_Angle_Object = row.Angle
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Angle_math.append(row.Angle)
#Calculate the angle at the vertex
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Angle_Final = 180 - Angle_math[0] - Angle_math[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows

&amp;nbsp;&amp;nbsp;&amp;nbsp; print(Angle_Final)

#add data to the layer file

&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.UpdateCursor("Poly2Point_lyr")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Angle = Angle_Final
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rows.updateRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del row
&amp;nbsp;&amp;nbsp;&amp;nbsp; del rows
&amp;nbsp;&amp;nbsp;&amp;nbsp; del Angle_math
#Export all the final angles in Poly2Point_lyr to a feature class

angle_output_location = "C:/Users/xxxxxxxxx/Desktop/Projects/CGN_Building_survey_validating/test.gdb/Vertex_Angles"
arcpy.CopyFeatures_management("Poly2Point_lyr", angle_output_location)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:13:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534656#M41881</guid>
      <dc:creator>PeterMetzger1</dc:creator>
      <dc:date>2021-12-11T23:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534657#M41882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Peter,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did you ever get that script to work on a whole data set?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Mar 2013 13:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534657#M41882</guid>
      <dc:creator>MarkMenzel</dc:creator>
      <dc:date>2013-03-14T13:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Polygon Angles at Vertices</title>
      <link>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534658#M41883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Peter,&lt;BR /&gt;&lt;BR /&gt;Did you ever get that script to work on a whole data set?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Mark&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have some code for calculating angles of lines, you could add to convert polygons to lines, split at vertices and use the following code to calc angles. There could prob be some major improvements on it, bit it works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
with arcpy.da.UpdateCursor(&amp;lt;outFeatureclass&amp;gt;, [&amp;lt;put fields to calc in here&amp;gt;])as rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Print the current line ID
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while count == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevm = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevX = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevY = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevm = m
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevX = endx
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; prevY = endy&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count = count+1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Feature {0}:".format(row[0]))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set start point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startpt = row[1].firstPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set Start coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; startx = startpt.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print startx
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; starty = startpt.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print starty
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set end point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endpt = row[1].lastPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set End coordinates
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endx = endpt.X
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print endx
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endy = endpt.Y
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print endy

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get slope of line
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; radian = math.atan((endx - startx)/(endy - starty))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m = radian*180 / math.pi
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (m&amp;lt;=0):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m+=360.0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; slope = repr(m)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; change = prevm-m
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print slope
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print change
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hope this helps and let me know if you have any questions&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:13:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-polygon-angles-at-vertices/m-p/534658#M41883</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2021-12-11T23:13:44Z</dc:date>
    </item>
  </channel>
</rss>

