<?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: Return the bearing of a polygon edge based on selection in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097818#M5998</link>
    <description>&lt;P&gt;Maybe something in this tool set &lt;A href="https://desktop.arcgis.com/en/arcmap/latest/manage-data/creating-new-features/reporting-cogo-descriptions.htm" target="_self"&gt;Reporting COGO descriptions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 22:27:05 GMT</pubDate>
    <dc:creator>BillFox</dc:creator>
    <dc:date>2021-09-13T22:27:05Z</dc:date>
    <item>
      <title>Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097735#M5997</link>
      <description>&lt;P&gt;Greetings folks,&lt;/P&gt;&lt;P&gt;Looking to be able to return the bearing of the side of a polygon based on a interaction.&lt;/P&gt;&lt;P&gt;I have a carto points feature class that I want to populate its F_ANGLE field with the bearing of the side in which intersects with a polygon. We use that bearing to change the symbology rotation. Any help would be great.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The image below shows a polygon and a point with symblogy interacting. I'd like to get the bearing of that intersection&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_1-1631555847574.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22876i8631587C6A1E20D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_1-1631555847574.png" alt="JS_Esri_1-1631555847574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have got this working for an intersection of a line feature but not a polygon (image below).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_0-1631555492520.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22875iED212F764C14539B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_0-1631555492520.png" alt="JS_Esri_0-1631555492520.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Code for the intersection of lines is below, replacing the feature with a polygon does not work. Looking for someone with a bit more coding knowledge for some help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var LinesFC = Intersects(FeatureSetByName($datastore, "Lines", ['objectid', ''], false), $feature)
if (Count(LinesFC) &amp;gt; 0) {
    var line = first(LinesFC)
    var geom = Geometry(line)
    var pt0 = geom.paths[0][0]
    var brg = Bearing(pt0, Geometry($feature))
    if (brg &amp;gt; 90 &amp;amp;&amp;amp; brg &amp;lt;= 360) {
        return (450 - brg)
    } 
    return (90 - brg)
}
return null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advanced.&lt;/P&gt;&lt;P&gt;-JS&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 22:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097735#M5997</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2021-09-13T22:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097818#M5998</link>
      <description>&lt;P&gt;Maybe something in this tool set &lt;A href="https://desktop.arcgis.com/en/arcmap/latest/manage-data/creating-new-features/reporting-cogo-descriptions.htm" target="_self"&gt;Reporting COGO descriptions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 22:27:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097818#M5998</guid>
      <dc:creator>BillFox</dc:creator>
      <dc:date>2021-09-13T22:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097924#M5999</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var PolyFC =Intersects(FeatureSetByName($datastore, "gewaesserkataster_sde.GWK_SDE_ADMIN.poly"), $feature)

// return early if no intersecting polygon is found
// doing it this way saves you from indenting everything in your if block
if(PolyFC == null || Count(PolyFC) == 0) {
  return null
}

// lines have the "paths" attribute, for polygons that's "rings"
var poly = First(PolyFC)
var geom = Geometry(poly)
var pt0 = geom.rings[0][0]
var brg = Bearing(pt0, Geometry($feature))
if (brg &amp;gt; 90 &amp;amp;&amp;amp; brg &amp;lt;= 360) {
  return (450 - brg)
} 
return (90 - brg)

// if that works for you, cool.
// I got really inconsistent results when testing this on irregular polygons, though, 
// so I'd go with something like this:

var poly = First(PolyFC)
var vertices = Geometry(poly).rings[0]
var sr = Geometry(poly).spatialReference
// loop through the vertices
for(var r=0; r&amp;lt;Count(vertices)-1; r++) {
  // create a line segment between 2 adjacent vertices
  var p0 = vertices[r]
  var p1 = vertices[r+1]
  var line = Polyline({"paths": [[ [p0.x, p0.y], [p1.x, p1.y] ]], "spatialReference": sr})
  // do nothing if $feature doesn't intersect that line segment
  if(Disjoint($feature, line)) {
    continue
  }
  // return the bearing of the line segment
  var brg = Bearing(p0, p1)
  if (brg &amp;gt; 90 &amp;amp;&amp;amp; brg &amp;lt;= 360) {
    return (450 - brg)
  } 
  return (90 - brg)
}
// if you land here, the feature intersects a polygon, but none of its edges
return null&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 06:42:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1097924#M5999</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-14T06:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098020#M6001</link>
      <description>&lt;P&gt;Thanks for your efforts here!!!!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately the solutions you provided an error by the arcade compiler (see below line 3)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_0-1631626084748.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22927iAE2246509FB57898/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_0-1631626084748.png" alt="JS_Esri_0-1631626084748.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I have seen this error before. the solution was to get a count of the initial FeatureSetByName intersection as seen below in line #2. Yet still gets an error with the geometry statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JS_Esri_1-1631626326291.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22929i0AF7725990B23009/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JS_Esri_1-1631626326291.png" alt="JS_Esri_1-1631626326291.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Where are you testing this? I am implementing this as as an Attribute rule on a enterprise geodatabase frim ArcGIS Pro 2.6.6. I wonder if there is an difference in environments.&lt;/P&gt;&lt;P&gt;Again you are a gem!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:32:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098020#M6001</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2021-09-14T13:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098027#M6002</link>
      <description>&lt;P&gt;Line 1: Try changing the boolean parameter (includeGeometry) to true.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyname" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyname&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098027#M6002</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-14T13:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098031#M6003</link>
      <description>&lt;P&gt;Also, I'm on 2.6.3, Enterprise GDB, so no big differences there.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 13:43:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098031#M6003</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2021-09-14T13:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Return the bearing of a polygon edge based on selection using Arcade</title>
      <link>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098067#M6004</link>
      <description>&lt;P&gt;Oh man how did I miss that!!! Genius.&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;you are my hero! I saw the same issue with inconsistent results with the first code but the second is working as expected!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 14:50:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-the-bearing-of-a-polygon-edge-based-on/m-p/1098067#M6004</guid>
      <dc:creator>Jake_S</dc:creator>
      <dc:date>2021-09-14T14:50:33Z</dc:date>
    </item>
  </channel>
</rss>

