<?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: Angle between internal polyline line segments in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682801#M22676</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If all you want is the bearing differences of vertices within a single polyline then a cursor can step through the vertices and calculate the angles like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# vertex_angle.py
# find change in angle along a polyline at each vertex
# assume :
# in a projected coordinate system, not dd
# don't know what to do with output, maybe add value to a point
# Kim Ollivier
# 29 October 2010
#
import arcgisscripting
import math
import sys

gp = arcgisscripting.create(9.3)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; inlay = sys.argv[1]
except :
&amp;nbsp;&amp;nbsp;&amp;nbsp; inlay = "d:/work/test.gdb/wiggle"
desc = gp.Describe(inlay)
shapefield = desc.ShapeFieldName
cur = gp.SearchCursor(inlay)
row = cur.next()
n = 0
m = 0
p = 0
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature",n
&amp;nbsp;&amp;nbsp;&amp;nbsp; for partNum in range(feat.partCount) :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part = feat.getPart(partNum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptLast = None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bearingLast = None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Part",m
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ptNum in range(part.count):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = part.next() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ptLast:
&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; bearing = math.atan2((pt.Y - ptLast.Y),(pt.X - ptLast.X))
&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; if bearingLast:
&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; delta = bearing - bearingLast
&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; print p,delta/math.pi*180.0
&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; bearingLast = bearing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptLast = pt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; n+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
del cur,row
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise getting the vertices required is a lot harder if you do not have arc-node topology available. You would have this in a coverage if you built for nodes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This provides a unique list of nodes and tags on each "polyline" for the node at each end in the attribute tables AAT and NAT. I could then run a valence script to count the number of segments at each node to assist with the angle calculations. A simple extension of the valence concept can tag nodes as sources, sinks or passthrough. I know that a network dataset has all these capabilites, but the relationships and status are not accessible for python scripting, so I build my own network attributes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To build arc-node topology that is accessible for scripting in ArcGIS there is a very good tool in ET GEOTools called RenodePolylines. To get implied nodes at a T junction, clean the layer to a temporary layer using ETGeotools CleanPolyline in the absence of workstation clean. I would make sure there were no multi-parts to complicate the calculations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is easy to then select each node and do some angle calculations between each segment. Rather than run a buffer I would just look up the last or first point of a polyline and then step back one vertex. A useful python function math.atan2() gives the absolute bearing of two points. The next issue is to get direct access to the polyline verticies. Opening a cursor on a featureclass is not enough, so I open it once and load the parts of the featureclass into Python list and dictionary structures. After processing in double-quick time, then open an update cursor and write out the results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It all sounds like reinventing Network in Python, and it is. Maybe this could be done with C#.NET and ArcObjects? I challenge anyone with idle time to a competition!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:44:07 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2021-12-12T04:44:07Z</dc:date>
    <item>
      <title>Angle between internal polyline line segments</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682799#M22674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to find the angle between internal polyline segments?&amp;nbsp; I do not want to find the azimuth or bearing of each line segment; but rather, the "turn angle" at each segment junction if one was to travel along the entire polyline. I am using ArcGIS 9.3-- Any help would be much appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Oct 2010 14:19:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682799#M22674</guid>
      <dc:creator>AustinDavis</dc:creator>
      <dc:date>2010-10-28T14:19:58Z</dc:date>
    </item>
    <item>
      <title>Re: Angle between internal polyline line segments</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682800#M22675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks- I'll take a look at it!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've yet to program in python but I have a lot of VB experience.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Oct 2010 18:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682800#M22675</guid>
      <dc:creator>AustinDavis</dc:creator>
      <dc:date>2010-10-28T18:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Angle between internal polyline line segments</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682802#M22677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I may be trying to do the same thing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm looking for a way to calculate the bearing of a polyline with two vertex points.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I'm using ArcGIS 10 so VBA coding wont work. Does any one have python or dot net coding to calculate bearing of a single polyline with only one segment in ArcGIS 10?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Aug 2011 23:56:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682802#M22677</guid>
      <dc:creator>AlexanderBeavis</dc:creator>
      <dc:date>2011-08-16T23:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Angle between internal polyline line segments</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682801#M22676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If all you want is the bearing differences of vertices within a single polyline then a cursor can step through the vertices and calculate the angles like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# vertex_angle.py
# find change in angle along a polyline at each vertex
# assume :
# in a projected coordinate system, not dd
# don't know what to do with output, maybe add value to a point
# Kim Ollivier
# 29 October 2010
#
import arcgisscripting
import math
import sys

gp = arcgisscripting.create(9.3)

try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; inlay = sys.argv[1]
except :
&amp;nbsp;&amp;nbsp;&amp;nbsp; inlay = "d:/work/test.gdb/wiggle"
desc = gp.Describe(inlay)
shapefield = desc.ShapeFieldName
cur = gp.SearchCursor(inlay)
row = cur.next()
n = 0
m = 0
p = 0
while row:
&amp;nbsp;&amp;nbsp;&amp;nbsp; feat = row.getValue(shapefield)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature",n
&amp;nbsp;&amp;nbsp;&amp;nbsp; for partNum in range(feat.partCount) :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; part = feat.getPart(partNum)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptLast = None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bearingLast = None
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Part",m
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ptNum in range(part.count):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = part.next() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ptLast:
&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; bearing = math.atan2((pt.Y - ptLast.Y),(pt.X - ptLast.X))
&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; if bearingLast:
&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; delta = bearing - bearingLast
&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; print p,delta/math.pi*180.0
&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; bearingLast = bearing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ptLast = pt
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; n+=1
&amp;nbsp;&amp;nbsp;&amp;nbsp; row = cur.next()
del cur,row
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise getting the vertices required is a lot harder if you do not have arc-node topology available. You would have this in a coverage if you built for nodes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This provides a unique list of nodes and tags on each "polyline" for the node at each end in the attribute tables AAT and NAT. I could then run a valence script to count the number of segments at each node to assist with the angle calculations. A simple extension of the valence concept can tag nodes as sources, sinks or passthrough. I know that a network dataset has all these capabilites, but the relationships and status are not accessible for python scripting, so I build my own network attributes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To build arc-node topology that is accessible for scripting in ArcGIS there is a very good tool in ET GEOTools called RenodePolylines. To get implied nodes at a T junction, clean the layer to a temporary layer using ETGeotools CleanPolyline in the absence of workstation clean. I would make sure there were no multi-parts to complicate the calculations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is easy to then select each node and do some angle calculations between each segment. Rather than run a buffer I would just look up the last or first point of a polyline and then step back one vertex. A useful python function math.atan2() gives the absolute bearing of two points. The next issue is to get direct access to the polyline verticies. Opening a cursor on a featureclass is not enough, so I open it once and load the parts of the featureclass into Python list and dictionary structures. After processing in double-quick time, then open an update cursor and write out the results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It all sounds like reinventing Network in Python, and it is. Maybe this could be done with C#.NET and ArcObjects? I challenge anyone with idle time to a competition!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:44:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/angle-between-internal-polyline-line-segments/m-p/682801#M22676</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-12T04:44:07Z</dc:date>
    </item>
  </channel>
</rss>

