<?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: Calculating polyline azimuth - code error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526913#M41287</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To get north azimuth angles; try it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; for x1y1x2y2 in [(0,0,1,1),(0,0,1,-1),(0,0,-1,-1),(0,0,-1,1)]:&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1,y1,x2,y2 = x1y1x2y2[0],x1y1x2y2[1],x1y1x2y2[2],x1y1x2y2[3]&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(math.degrees(math.atan2((x2 - x1),(y2 - y1))))&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;45.0&lt;/P&gt;&lt;P&gt;135.0&lt;/P&gt;&lt;P&gt;-135.0&lt;/P&gt;&lt;P&gt;-45.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The += is shorthand for degBearing = degBearing + 360.0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Feb 2015 21:35:10 GMT</pubDate>
    <dc:creator>BruceHarold</dc:creator>
    <dc:date>2015-02-19T21:35:10Z</dc:date>
    <item>
      <title>Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526898#M41272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi. I'm trying to run a Python script in the field calculator to output the azimuth values of a series of polylines. However, everytime I try to run the code it throws the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"File "&amp;lt;string&amp;gt;", line 2, in GetAzimuthPolyline&lt;/P&gt;&lt;P&gt;AttributeError: 'str' object has no attribute 'x'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateField)."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code block I am using is:&lt;/P&gt;&lt;OL class="dp-c" start="1"&gt;&lt;LI&gt;import math&amp;nbsp; &lt;/LI&gt;&lt;LI&gt;def GetAzimuthPolyline(shape):&amp;nbsp; &lt;/LI&gt;&lt;LI&gt; radian = math.atan((shape.lastpoint.x - shape.firstpoint.x)/(shape.lastpoint.y - shape.firstpoint.y))&amp;nbsp; &lt;/LI&gt;&lt;LI&gt; degrees = radian * 180 / math.pi&amp;nbsp; &lt;/LI&gt;&lt;LI&gt; return degrees&amp;nbsp; &lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I sourced the code from this thread &lt;A href="https://community.esri.com/thread/20473"&gt;Calculate angle of each line in a polyline shapefile&lt;/A&gt;‌. It seems to be working for the people in the thread but not for me. I'm running Arc 10.1 with the basic license, by the way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone see where this is going wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 08:43:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526898#M41272</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T08:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526899#M41273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A screen grab of what you are using would help since the code block seems incomplete and improperly formatted.&amp;nbsp; Also, you are running this with the shapefield as input?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 09:33:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526899#M41273</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-08-05T09:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526900#M41274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here are some screenshots of what I've been doing:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Calculate field_python.jpg" class="jive-image image-1" src="/legacyfs/online/2980_Calculate field_python.jpg" style="width: 620px; height: 472px;" /&gt;&lt;/P&gt;&lt;P&gt;And this is the error that I am getting:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Python_error.jpg" class="jive-image image-2" src="https://community.esri.com/legacyfs/online/3029_Python_error.jpg" style="width: 620px; height: 420px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 09:44:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526900#M41274</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T09:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526901#M41275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See the attached image, you were missing the bottom part of the dialog I think.&amp;nbsp; I am using the field calculator which is much quicker&lt;/P&gt;&lt;P&gt;Also ensure that your field is a Double field with the appropriate width and precision.&lt;IMG __jive_id="3025" alt="codeblock.jpg" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/3025_codeblock.jpg" style="height: auto;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 10:25:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526901#M41275</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-08-05T10:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526902#M41276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;By the bottom part, do you mean the "test = test(!shape!)" bit? Should I put this below my code block or in the 'Expression' box?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had been using a Float field, so have made a Double field called 'Angle' to see if this works better. But Arc keeps changing 'Angle' back to a Float, any idea why it won't let me use a Double field?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 10:43:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526902#M41276</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T10:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526903#M41277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Camilla,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What i see from your screen shot is you are trying to calculate value for field &lt;STRONG&gt;Shape &lt;/STRONG&gt;and you are passing your shape input as &lt;STRONG&gt;Shape&lt;/STRONG&gt; field again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the data type of Shape field? is it a number or geometry?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 10:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526903#M41277</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-08-05T10:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526904#M41278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, yeah I realised that I was doing that. Hence creating the new 'Angle' field because the 'Shape' field was geometry. But when I try running it to fill the 'Angle' field I now get a generic syntax error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 10:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526904#M41278</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T10:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526905#M41279</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Last kick.&amp;nbsp; Add a double field, precision 16, scale 4&lt;/P&gt;&lt;P&gt;emulate the field calculator expression before heading to the tool in arctoolbox&lt;IMG alt="test1.jpg" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/3032_test1.jpg" style="width: 620px; height: 487px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 11:01:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526905#M41279</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-08-05T11:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526906#M41280</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah ha! It's just worked. This is the set up that worked:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Calculate field_python_success!.jpg" class="jive-image image-1" src="/legacyfs/online/3030_Calculate field_python_success!.jpg" style="width: 620px; height: 531px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only problem is that it is giving me a negative output (-61 degrees in the case of the tester polyline that I used). How can I make the code output the azimuth in the familar True North 0-360 degree output?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 11:02:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526906#M41280</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T11:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526907#M41281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;def GetAzimuthPolyline(shape):&lt;/P&gt;&lt;P&gt; radian = math.atan((shape.lastPoint.X - shape.firstPoint.X)/(shape.lastPoint.Y - shape.firstPoint.Y))&lt;/P&gt;&lt;P&gt; degrees = math.degrees(radian)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if degrees &amp;lt; 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp; return degrees + 360 &lt;/P&gt;&lt;P&gt; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp; return degrees&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 11:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526907#M41281</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-08-05T11:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526908#M41282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, that's done it. Thanks to both of you for your help, much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 11:57:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526908#M41282</guid>
      <dc:creator>CamillaRootes</dc:creator>
      <dc:date>2014-08-05T11:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526909#M41283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the postings, but I just tried this on an NHD dataset looking at the azimuths of stream polylines.&amp;nbsp; It doesn't return the correct azimuth&amp;nbsp; The azimuth -90 to 90 works, but between 90 and 270 degrees are incorrect. The streams flow direction is reversed.&amp;nbsp; I am going to look at the math, and will post if I see an improved answer.&lt;/P&gt;&lt;P&gt; &lt;IMG alt="stream_azimuth.PNG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/63238_stream_azimuth.PNG" style="width: 620px; height: 279px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 21:52:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526909#M41283</guid>
      <dc:creator>DavidHarbor</dc:creator>
      <dc:date>2015-02-18T21:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526910#M41284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is some code that works for me, where the "answer" does not as shown in previous post.&lt;/P&gt;&lt;P&gt;def CalculaAzimuth(linea):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (hasattr(linea,'type') and linea.type == 'polyline'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xf = linea.firstPoint.X&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yf = linea.firstPoint.Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xl = linea.lastPoint.X&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yl = linea.lastPoint.Y&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dX = xl - xf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dY = yl - yf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PI = math.pi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Azimuth = 0 #Default case, dX = 0 and dY &amp;gt;= 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dX &amp;gt; 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Azimuth = 90 - math.atan( dY / dX ) * 180 / PI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif dX &amp;lt; 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Azimuth = 270 - math.atan( dY / dX )* 180 / PI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif dY &amp;lt; 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Azimuth = 180&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Azimuth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return False&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which comes from here&lt;/P&gt;&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/15480450/syntax-errors-when-calculating-azimuth-with-python-in-arcgis-10" title="http://stackoverflow.com/questions/15480450/syntax-errors-when-calculating-azimuth-with-python-in-arcgis-10"&gt;Syntax Errors when Calculating Azimuth with Python in Arcgis 10 - Stack Overflow&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="stream_azimuth.PNG" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/63483_stream_azimuth.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Wish I could make use of "atan2(y,x)" but I couldn't get it to return 0-360 correctly in all quadrants.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 20:37:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526910#M41284</guid>
      <dc:creator>DavidHarbor</dc:creator>
      <dc:date>2015-02-19T20:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526911#M41285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;#Function to return the north azimuth bearing of a line segment in degrees&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;def NorthAzimuth(x1,y1,x2,y2):&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; degBearing = math.degrees(math.atan2((x2 - x1),(y2 - y1)))&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (degBearing &amp;lt; 0):&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; degBearing += 360.0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return degBearing&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 20:47:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526911#M41285</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-02-19T20:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526912#M41286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two questions Bruce&lt;/P&gt;&lt;P&gt;why reverse the y and x&amp;nbsp; in the atan function?&lt;/P&gt;&lt;P&gt;what is the operator +=&amp;nbsp; ?&lt;/P&gt;&lt;P&gt;(sorry, I'm a python noob)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 21:04:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526912#M41286</guid>
      <dc:creator>DavidHarbor</dc:creator>
      <dc:date>2015-02-19T21:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526913#M41287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To get north azimuth angles; try it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; for x1y1x2y2 in [(0,0,1,1),(0,0,1,-1),(0,0,-1,-1),(0,0,-1,1)]:&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x1,y1,x2,y2 = x1y1x2y2[0],x1y1x2y2[1],x1y1x2y2[2],x1y1x2y2[3]&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(math.degrees(math.atan2((x2 - x1),(y2 - y1))))&lt;/P&gt;&lt;P&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;45.0&lt;/P&gt;&lt;P&gt;135.0&lt;/P&gt;&lt;P&gt;-135.0&lt;/P&gt;&lt;P&gt;-45.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The += is shorthand for degBearing = degBearing + 360.0&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 21:35:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526913#M41287</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2015-02-19T21:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating polyline azimuth - code error</title>
      <link>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526914#M41288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sweet. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Feb 2015 21:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculating-polyline-azimuth-code-error/m-p/526914#M41288</guid>
      <dc:creator>DavidHarbor</dc:creator>
      <dc:date>2015-02-19T21:50:22Z</dc:date>
    </item>
  </channel>
</rss>

