<?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: Obtaining stream flow direction in ArcGIS Spatial Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582404#M8435</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;Although this type of analysis is normally done using the raster format, it can be done using a featureclass (shapefile). Assuming that you are interested in an angle between the start point and the end point of each feature you could do this:&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;open the attribute table of your shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;add a new field that will hold the cardinal flow direction, make sure it is a text field (let's call this field "CardFD")&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;right click on your new field "CardFD" and select "Field Calculator..." to open the Field Calculator&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Choose Python as parser&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Switch the "Show Codeblock" on&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Paste the code below in the "Pre-Logic Script Code":&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from math import atan2, pi

def getCardinal(angle):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lstCardinal = [[22.5,"E"], [67.5, "NE"], [112.5, "N"],
&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; [157.5, "NW"], [202.5, "W"], [247.5, "SW"],
&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; [292.5, "S"], [337.5, "SE"], [360, "E"]]

&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in lstCardinal:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = item[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle &amp;lt; value:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cardinal = item[1]
&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; return cardinal

def calcGeomCardinality(polyline):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = polyline.firstPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = polyline.lastPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = (atan2(pnt2.Y - pnt1.Y, pnt2.X - pnt1.X)) * 180.0 / pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle_deg &amp;lt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = 360 + angle_deg
&amp;nbsp;&amp;nbsp;&amp;nbsp; return getCardinal(angle_deg)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Paste the line below in as formula (just below "CardFD =")&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;calcGeomCardinality( !SHAPE!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Click "OK"&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;This will take each polyline feature and extract the from and to node from it. Next it will calculate the angle and parse it to cardinal flow direction.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;You can also write the angle itself to a new field:&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;add a new field (double or&amp;nbsp; float) that can hold the angle between the start and end point . Let's call this field "FlowAngle"&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;right click on your new field "FlowAngle" and select "Field Calculator..." to open the Field Calculator&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;it will probably show the code from cardinal flow direction. Replace the code in the "Pre-Logic Script Code" by&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from math import atan2, pi

def getAngle(polyline):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = polyline.firstPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = polyline.lastPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = (atan2(pnt2.Y - pnt1.Y, pnt2.X - pnt1.X)) * 180.0 / pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle_deg &amp;lt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = 360 + angle_deg
&amp;nbsp;&amp;nbsp;&amp;nbsp; return angle_deg&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Paste the line below in as formula (just below "FlowAngle=")&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;getAngle( !SHAPE!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Click "OK"&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;If you are going to perform some analysis to determine the predominant angle, please be aware that the resulting angle does not have to be representative for the area.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Xander...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The steps you outlined were great and presented me with some other challenges and questions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Forgive me as I am far from understanding Python script and programing. Although I have the actual stream meandering lengths between the nodes, is there a way to modify the script to calculate the intra-nodal distance as well as the direction? As you mentioned, "the resulting angle I received was not always representative for the area when taking into account all of my stream features." &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The lengths of the features in the feature class are (almost) invariably going to be greater than the distance between nodes. I believe the stream-network statistics I am trying to obtain will be better served by the straight distance between nodes (as the crow flies) than they will by the actual length of the feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, is there a way to modify the script or a tool I can use to calculate the inter nodal distance and obtain a flow angle and cardinal direction? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, any and all information is greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:02:19 GMT</pubDate>
    <dc:creator>MarkBrown</dc:creator>
    <dc:date>2021-12-12T01:02:19Z</dc:date>
    <item>
      <title>Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582397#M8428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a polyline stream layer (shapefile) and I want to know if there is a way to find the cardinal flow direction&amp;nbsp; (N, NE, E, SE, S...) of each individual stream segment?&amp;nbsp; I have a DEM, but I am not interested in the terrain flow direction that water would normally flow. I am looking to find the cardinal flow direction of the stream(s) segments themselves. My ultimate goal is to determine the average stream flow direction within a polygon layer using a spatial join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure if this matters, but I have From_Nodes and To_Nodes, reach codes and distances in my attribute table. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this makes sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any and all information, tools, tips, tricks is greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Feb 2014 14:28:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582397#M8428</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-02-20T14:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582398#M8429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although this type of analysis is normally done using the raster format, it can be done using a featureclass (shapefile). Assuming that you are interested in an angle between the start point and the end point of each feature you could do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;open the attribute table of your shapefile&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;add a new field that will hold the cardinal flow direction, make sure it is a text field (let's call this field "CardFD")&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;right click on your new field "CardFD" and select "Field Calculator..." to open the Field Calculator&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Choose Python as parser&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Switch the "Show Codeblock" on&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Paste the code below in the "Pre-Logic Script Code":&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from math import atan2, pi

def getCardinal(angle):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lstCardinal = [[22.5,"E"], [67.5, "NE"], [112.5, "N"],
&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; [157.5, "NW"], [202.5, "W"], [247.5, "SW"],
&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; [292.5, "S"], [337.5, "SE"], [360, "E"]]

&amp;nbsp;&amp;nbsp;&amp;nbsp; for item in lstCardinal:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = item[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle &amp;lt; value:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cardinal = item[1]
&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; return cardinal

def calcGeomCardinality(polyline):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = polyline.firstPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = polyline.lastPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = (atan2(pnt2.Y - pnt1.Y, pnt2.X - pnt1.X)) * 180.0 / pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle_deg &amp;lt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = 360 + angle_deg
&amp;nbsp;&amp;nbsp;&amp;nbsp; return getCardinal(angle_deg)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Paste the line below in as formula (just below "CardFD =")&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;calcGeomCardinality( !SHAPE!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Click "OK"&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;This will take each polyline feature and extract the from and to node from it. Next it will calculate the angle and parse it to cardinal flow direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can also write the angle itself to a new field:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;add a new field (double or&amp;nbsp; float) that can hold the angle between the start and end point . Let's call this field "FlowAngle"&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;right click on your new field "FlowAngle" and select "Field Calculator..." to open the Field Calculator&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;it will probably show the code from cardinal flow direction. Replace the code in the "Pre-Logic Script Code" by&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from math import atan2, pi

def getAngle(polyline):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = polyline.firstPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = polyline.lastPoint
&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = (atan2(pnt2.Y - pnt1.Y, pnt2.X - pnt1.X)) * 180.0 / pi
&amp;nbsp;&amp;nbsp;&amp;nbsp; if angle_deg &amp;lt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; angle_deg = 360 + angle_deg
&amp;nbsp;&amp;nbsp;&amp;nbsp; return angle_deg&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Paste the line below in as formula (just below "FlowAngle=")&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;getAngle( !SHAPE!)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;Click "OK"&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;BR /&gt;&lt;SPAN&gt;If you are going to perform some analysis to determine the predominant angle, please be aware that the resulting angle does not have to be representative for the area.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582398#M8429</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T01:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582399#M8430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Xander....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your informative reply.&amp;nbsp; I did just as you indicated and although I received an error (000539 : Error message from Python), the CardFD field did populate with a cardinal direction. I have spot checked a number of the individual segments and they appear to be in line with the cardinal direction. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also received the same error for the FlowAngle field, but the field did populate with an angle. However, the FlowAngle does not always appear to be representative of the cardinal direction (i.e. FlowAngle 2.829 was populated for an East cardinal direction). In my thinking that should be North. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I greatly appreciate your help and time in responding to my inquery. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 13:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582399#M8430</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-02-25T13:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582400#M8431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error refers to something that went wrong with the field calculation. Since the code does not account for any type of error (polyline of 0 length, or polyline that has the same start and end point) there can be many reason for the error to occur.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The angle is arithmetic (not geographic). 0° is East and the angle increments counter clockwise:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-family:courier new;"&gt;&amp;lt; 22.5: "E"&lt;BR /&gt;&amp;lt; 67.5: "NE"&lt;BR /&gt;&amp;lt;112.5: "N"&lt;BR /&gt;&amp;lt;157.5: "NW"&lt;BR /&gt;&amp;lt;202.5: "W"&lt;BR /&gt;&amp;lt;247.5: "SW"&lt;BR /&gt;&amp;lt;292.5: "S"&lt;BR /&gt;&amp;lt;337.5: "SE"&lt;BR /&gt;&amp;lt;360.0: "E"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 13:51:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582400#M8431</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-02-25T13:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582401#M8432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you considered the Linear Direction Mean tool? You can wrap this up in a very simple model. May not be the most speedy way of doing this but will generate a direction line for every segment. See the model below, knocked this up in 2 minutes...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could run this on a subset of your data if you select some lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]31729[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 13:57:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582401#M8432</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-02-25T13:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582402#M8433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Xander...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the follow up.&amp;nbsp; After I sent my post I realized I was thinking geographic.&amp;nbsp; It was too early in the morning.&amp;nbsp; Again thanks for the post. Everything seems to be in line and makes sense.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 17:16:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582402#M8433</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-02-25T17:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582403#M8434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Duncan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not tried the Linear Direction Mean Tool.&amp;nbsp; I will have a look at it and see how it works.&amp;nbsp; I greatly appreciate the response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2014 17:18:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582403#M8434</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-02-25T17:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582405#M8436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can compute the straight line distance of any polyline with the following python field calculate. First create a field of type double then run a calculate with the python expression getSLDist(!shape!) and the pre-logic script code is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
def getSLDist(geom):
&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Get the end points of the polyline
&amp;nbsp; &lt;/SPAN&gt;fp = geom.firstPoint
&amp;nbsp; tp = geom.lastPoint

&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Create an Array object and add points to it
&amp;nbsp; &lt;/SPAN&gt;array = arcpy.Array()
&amp;nbsp; array.add(fp)
&amp;nbsp; array.add(tp)
&lt;SPAN style="color:#008000;"&gt;
&amp;nbsp; # Create a polyline from array, as it only has 2 points in it
&amp;nbsp; # it must be a straight line, then return its length&lt;/SPAN&gt;
&amp;nbsp; line = arcpy.Polyline(array)
&amp;nbsp; dist = line.length
&amp;nbsp; return dist
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582405#M8436</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-12T01:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582406#M8437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Mark,&lt;BR /&gt;&lt;BR /&gt;You can compute the straight line distance of any polyline with the following python field calculate. First create a field of type double then run a calculate with the python expression getSLDist(!shape!) and the pre-logic script code is:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
def getSLDist(geom):
&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Get the end points of the polyline
&amp;nbsp; &lt;/SPAN&gt;fp = geom.firstPoint
&amp;nbsp; tp = geom.lastPoint

&amp;nbsp; &lt;SPAN style="color:#008000;"&gt;# Create an Array object and add points to it
&amp;nbsp; &lt;/SPAN&gt;array = arcpy.Array()
&amp;nbsp; array.add(fp)
&amp;nbsp; array.add(tp)
&lt;SPAN style="color:#008000;"&gt;
&amp;nbsp; # Create a polyline from array, as it only has 2 points in it
&amp;nbsp; # it must be a straight line, then return its length&lt;/SPAN&gt;
&amp;nbsp; line = arcpy.Polyline(array)
&amp;nbsp; dist = line.length
&amp;nbsp; return dist
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;Duncan&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Duncan...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply.&amp;nbsp; What am I supposed to add to the CodeBlock box (i.e. Straight_Length =)?&amp;nbsp; I placed the script code into the pre-logic box, but my OK box is greyed out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I run the field calculator with the script in the codeblock, I receive a Python error: 000539 : Error message from Python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:02:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582406#M8437</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2021-12-12T01:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582407#M8438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Having created a field of type double, you right click on field header run field calculator and complete as shown below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]31854[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Duncan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Feb 2014 21:56:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582407#M8438</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2014-02-27T21:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582408#M8439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see Duncan has already provided you with a good way to calculate the intra-nodal distance. I was wondering however, since your goal is to "&lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;determine the average stream flow direction within a polygon layer&lt;/SPAN&gt;&lt;SPAN&gt;" and you don't want to use your DEM (aspect) for this purpose, you could do something else. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What if you would create fields for each cardinal flow direction and each field would be filled with the sum of the lengths of coordinate pairs within each stream in that cardinal flow direction. My guess is that this would provide a better understanding of the flow direction once you summarize it within a polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 04:50:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582408#M8439</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-02-28T04:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582409#M8440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;I see Duncan has already provided you with a good way to calculate the intra-nodal distance. I was wondering however, since your goal is to "&lt;SPAN style="font-style:italic;"&gt;determine the average stream flow direction within a polygon layer&lt;/SPAN&gt;" and you don't want to use your DEM (aspect) for this purpose, you could do something else. &lt;BR /&gt;&lt;BR /&gt;What if you would create fields for each cardinal flow direction and each field would be filled with the sum of the lengths of coordinate pairs within each stream in that cardinal flow direction. My guess is that this would provide a better understanding of the flow direction once you summarize it within a polygon.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Xander and Duncan...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Before I saw Duncan's latest post I was able to figure out how to run the script. I am getting a calculation, but for some reason the straight line distances that are calculated aren't what they should be.&amp;nbsp; They are much smaller (way smaller) than the actual stream lengths. My projections and coordinate systems agree.&amp;nbsp; I'm not sure if the issue resides in the from and to nodes in the attribute table or what. You folks have been a tremendous help thus far, but I'm still perplexed in trying to obtain the straight line distances.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2014 18:19:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582409#M8440</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-02-28T18:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582410#M8441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This sounds a lot like it has to do with the coordinate systems. Can you specify the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- coordinate system of your streams dataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- coordinate system of your data frame&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If both are geographic, can you provide me a projected coordinate that suits your data (for the length calculation)? Probably the&amp;nbsp; straight line geometry has to be created with the spatial reference of the source, and if that is geographic, it needs to be projected to obtain the proper length. This can all be done in the field calculator script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just to be sure can you also provide an example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- start coordinate&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- end coordinate&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- distance measured manually (the correct distance)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- distance calculated by the script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Mar 2014 04:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582410#M8441</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-03-03T04:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582411#M8442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;This sounds a lot like it has to do with the coordinate systems. Can you specify the following:&lt;BR /&gt;- coordinate system of your streams dataset&lt;BR /&gt;- coordinate system of your data frame&lt;BR /&gt;&lt;BR /&gt;If both are geographic, can you provide me a projected coordinate that suits your data (for the length calculation)? Probably the&amp;nbsp; straight line geometry has to be created with the spatial reference of the source, and if that is geographic, it needs to be projected to obtain the proper length. This can all be done in the field calculator script.&lt;BR /&gt;&lt;BR /&gt;Just to be sure can you also provide an example:&lt;BR /&gt;- start coordinate&lt;BR /&gt;- end coordinate&lt;BR /&gt;- distance measured manually (the correct distance)&lt;BR /&gt;- distance calculated by the script&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Xander,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me back up just a bit and give you an idea of my data set.&amp;nbsp; I have NHD data with thousands of individual stream segments. If you recall my initial pursuit was to find the stream length and flow direction of the individual segments. The information from you and Duncan proved fruitful in that effort. But as you recall, my combined flow direction was not matching up to my needs.&amp;nbsp; I then asked how I could get a straight line distance between my starting and ending nodes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My nodes were in some kind of decimal units....(I am guessing miles) because when I calculated the stream length in miles (using field calculator) everything pretty much agreed, but my straight line distances from the above python script did not. As a novice to all this, I discovered that I probably needed coordinates for my nodes in order to get a straight line distance between the first and last nodes as well as a bearing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So....in order to get to a straight line distance, I had to Dissolve my dataset based on my reachcodes....meaning I had multilple segments that made up one complete stream segment. That reduced the number of individual segments I had to deal with, which did not carry over the original decimal node values. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then created separate fields to calculate the lat/long coordinates of my TO and FROM nodes. It appears that I can calculate the straight line distance. It will calculate it in miles, but I can do a conversion with field calculator.&amp;nbsp; If I calculate geometry, it will calculate the "actual stream length". So, what I need is to calculate the flow angle or bearing from that line, but I get a 99999 error It will not calculate the field based on the python script provided earlier nor will it calculate my flow angles or cardinal bearing. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example in my combined streams layer.....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Streams layer and data frame:&amp;nbsp;&amp;nbsp; Projected Coordinate System:NAD_1983_Lambert_Conformal_Conic&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Geographic Coordinate System: GCS_North_American_1983&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this particular example it is the result of two stream segments that I combined through DISSOLVE based on reach code.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From_Node_X (-80.42511)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;From_Node_Y (39.72707)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To_Node_X (-80.43147)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To_Node_Y (39.72133)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Actual stream length (calculate geometry) 0.57185 miles &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Straight line distance: 2752.176 feet&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Long story short....from my new dissolved data, I need to once again find the resultant flow angle or bearing from my start and end points of my nodes. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your time...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 18:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582411#M8442</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-03-04T18:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582412#M8443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If your data is located somewhere at the border of Pennsylvania and West Virginia, the coordinates are in decimal degrees (not miles). The coordinates seem to correspond to a stream, just next to the Golden Oaks rd (PA 18).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using decimal degrees to calculate the angle and the straight distance in the scrips will not give correct answers. The coordinates should be projected first. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know what the reason is for the calculation to trow a 99999 error. If you are willing to share a small part of your data (streams) I can have a look.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 07:39:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582412#M8443</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-03-05T07:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582413#M8444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;If your data is located somewhere at the border of Pennsylvania and West Virginia, the coordinates are in decimal degrees (not miles). The coordinates seem to correspond to a stream, just next to the Golden Oaks rd (PA 18).&lt;BR /&gt;&lt;BR /&gt;Using decimal degrees to calculate the angle and the straight distance in the scrips will not give correct answers. The coordinates should be projected first. &lt;BR /&gt;&lt;BR /&gt;I don't know what the reason is for the calculation to trow a 99999 error. If you are willing to share a small part of your data (streams) I can have a look.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Xander...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Indeed, I should have originally provided you with a snippit of my data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the first image (original data)....this was my data as I started with it.&amp;nbsp; As you can see, I have multiple reach codes for individual segments. In my From and To nodes, there are decimal units....which are likely in miles because the stream line distances match up between the nodes. I did not originally have Lat/Long coordinates and used the calculate geometry to calculate those fields. The FlowAngle and CardFD fields were calculated based on the previous python scripts. BEFORE I HAD EVEN OBTAINED THE LAT/LONG COORDINATES.&amp;nbsp; And the script appeared to do what you had said it would.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But for my flow direction data to be more representative of my polygon layer, my thinking is that it would be best to combine the streams based on the same reach codes.&amp;nbsp; Thus the combined stream would have a single From and To node. This meant DISSOLVING my data or using the unsplit line tool to accomplish that task (Data Dissolve). Both seemed to acquire the same reasults. After dissolviing my data, I again calculated the Lat/Long coordinates of the From and To nodes. From there I believed I should be able to get the actual stream length, the straight line stream length and the flow angle or flow bearing of the straight line distance.....my original intended goal.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I again tried running the scripts, I acquired the 99999 error code.&amp;nbsp; That is where I stand at this point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this makes sense...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for your time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 11:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582413#M8444</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-03-05T11:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582414#M8445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I was asking for a few streams, I was refering to a featureclass. Maybe you can attach a few streams as featureclass in a zipped fgdb or as a zipped shapefile (although some fieldnames will be renamed when exporting to shapefile). This way I can look at the geometry itself and the spatial reference and test my script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 11:43:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582414#M8445</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-03-05T11:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582415#M8446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;When I was asking for a few streams, I was refering to a featureclass. Maybe you can attach a few streams as featureclass in a zipped fgdb or as a zipped shapefile (although some fieldnames will be renamed when exporting to shapefile). This way I can look at the geometry itself and the spatial reference and test my script.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please find the attached zipped FGDB.&amp;nbsp; I hope this works for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 12:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582415#M8446</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-03-05T12:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582416#M8447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I had some problems with the "custom" coordinate system, but I have attached a toolbox with the functionality and also an updated file geodatabase. Unzip the toolbox ("toolshare2.zip") and navigate with the ArcCatalog window to the unzip location. Try the tools inside. Hope they work for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The SL distance (length) that is returned follows the linear unit of the input featureclass. In your case it is US_Foot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Mar 2014 13:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582416#M8447</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-03-05T13:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining stream flow direction</title>
      <link>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582417#M8448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi Mark,&lt;BR /&gt;&lt;BR /&gt;I had some problems with the "custom" coordinate system, but I have attached a toolbox with the functionality and also an updated file geodatabase. Unzip the toolbox ("toolshare2.zip") and navigate with the ArcCatalog window to the unzip location. Try the tools inside. Hope they work for you.&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The SL distance (length) that is returned follows the linear unit of the input featureclass. In your case it is US_Foot.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Xander&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Xander...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Worked like a charm.&amp;nbsp; I tried it on a couple of other datasets and there does not seem to be any issues.&amp;nbsp; The data is consistent to what I was looking for.&amp;nbsp; Much more manageable as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One other question.....if in the future I wanted to further divide the cardinal flow directions from the earlier script into even smaller units of degrees (i.e. 0-11.25 degrees N, 11.25 - 22.5 NNE, etc...) I could modify that script to do calculate those flow directions/angles, correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You and Duncan have been of great help.&amp;nbsp; Thanks for all your time and patience with me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Greatly appreciated...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;v/r&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Mark&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 Mar 2014 11:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-spatial-analyst-questions/obtaining-stream-flow-direction/m-p/582417#M8448</guid>
      <dc:creator>MarkBrown</dc:creator>
      <dc:date>2014-03-06T11:20:13Z</dc:date>
    </item>
  </channel>
</rss>

