<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculate longest length of polygon in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311718#M1035</link>
    <description>&lt;P&gt;You are a genius.&lt;/P&gt;&lt;P&gt;I used the &lt;SPAN&gt;distanceGeodetic function and I got the same as the widget.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I just need to update for multiple segments for the sides, so it can add up for the longest side made up of multiple segments.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks so much!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2023 19:46:00 GMT</pubDate>
    <dc:creator>BigLouC</dc:creator>
    <dc:date>2023-07-25T19:46:00Z</dc:date>
    <item>
      <title>Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238391#M675</link>
      <description>&lt;P&gt;I am trying to make an attribute rule that automatically calculates the length of the longest side of a polygon, but having difficulty figuring it out.&lt;/P&gt;&lt;P&gt;Polygon will always be a 4 sided rectangle, but may be oriented in any direction.&lt;/P&gt;&lt;P&gt;Does any know of a way to accomplish this as an attribute rule?&lt;/P&gt;&lt;P&gt;Basically, need the X value here:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_1-1670348539705.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57774iA5CE4FA7D104071E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_1-1670348539705.png" alt="RhettZufelt_1-1670348539705.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help,&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 17:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238391#M675</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-12-06T17:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238621#M676</link>
      <description>&lt;LI-CODE lang="javascript"&gt;var distances = []
// get the polygon parts
var rings = Geometry($feature).rings
// loop over the parts
for(var r in rings) {
    var ring = rings[r]
    // loop over the vertices (skip first)
    for(var v = 1; v &amp;lt; Count(ring); v++) {
        Push(distances, Distance(ring[v - 1], ring[v]))
    }
}
return Max(distances)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will get the longest side of any polygon, no matter the part count or the form. You could simplify it by only extracting the first ring and checking only the first three vertices (giving you the two sides), but it would not make any noticeable time difference.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 07:43:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238621#M676</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-07T07:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238623#M677</link>
      <description>&lt;P&gt;For completeness, here's the simple expression for a rectangle:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var ring = Geometry($feature).rings[0]
var d1 = Distance(ring[0], ring[1])
var d2 = Distance(ring[1], ring[2])
return Max(d1, d2)&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1670399501541.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57838i122167F321EFD207/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1670399501541.png" alt="JohannesLindner_0-1670399501541.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 07:51:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238623#M677</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-07T07:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238778#M681</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;, this is exactly what I needed.&lt;/P&gt;&lt;P&gt;Only thing I see that is weird, is that it was reporting distances in meters, even though my map and data are in State Plane feet.&lt;/P&gt;&lt;P&gt;Documentation says 'Distance' defaults to &lt;SPAN&gt;the spatial reference of the data, but that does not seem to be the case with a calculation attribute rule.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Adding the units parameter did the trick though:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Push(distances, Distance(ring[v - 1], ring[v], 'feet'))&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:19:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238778#M681</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-12-07T16:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311262#M1024</link>
      <description>&lt;P&gt;Hello Johannes,&lt;/P&gt;&lt;P&gt;Your solution helped me out, but on my end, it seems to be off by .10.&lt;/P&gt;&lt;P&gt;I am using miles, and when measuring with the ruler widget, say I get .85 miles, your code gives me .95.&lt;/P&gt;&lt;P&gt;Or another one says 1.25 on the widget, the code returns 1.35 miles.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the State Plane have anything to do with this?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 22:25:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311262#M1024</guid>
      <dc:creator>BigLouC</dc:creator>
      <dc:date>2023-07-24T22:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311283#M1027</link>
      <description>&lt;P&gt;Hmm. For me, the widget returns slightly larger values, but that's because it only displays two significant digits and seems to always round up.&lt;/P&gt;&lt;P&gt;It might be the coordinate system, but I have absolutely no experience working in State Plane, so I can't say anything about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your polygons cover great distances, you might want to use DistanceGeodetic to account for Earth's curvature. Make sure that your polygons are inside your state zone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, make sure that the code and the measure widget use the same distance method (planar or geodesic), and that you actually snap to the polygon's vertices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the Arcade Geometry functions warn about generalization errors when using them for labeling or symbology:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;EM&gt;Feature geometries in the visualization and labeling profiles are generalized according to the view's scale resolution to improve drawing performance. Therefore, using a feature's geometry (i.e.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;$feature) as input to any geometry function in these contexts will return different results at each scale level. Other profiles, such as popup, provide the full resolution geometry.&lt;/EM&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I haven't seen this effect yet, but I expect it would show up for polygons with many vertices.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If none of these help, I suggest doing the distance calculation manually and comparing it to both measuring widget and code. At least then you know which one is correct.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 23:26:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311283#M1027</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-07-24T23:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311702#M1034</link>
      <description>&lt;P&gt;Thank you very much for your prompt response.&lt;/P&gt;&lt;P&gt;Yes, my polygons do have multiple vertices.&lt;/P&gt;&lt;P&gt;I will try your suggestions.&lt;/P&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 19:21:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311702#M1034</guid>
      <dc:creator>BigLouC</dc:creator>
      <dc:date>2023-07-25T19:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate longest length of polygon</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311718#M1035</link>
      <description>&lt;P&gt;You are a genius.&lt;/P&gt;&lt;P&gt;I used the &lt;SPAN&gt;distanceGeodetic function and I got the same as the widget.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I just need to update for multiple segments for the sides, so it can add up for the longest side made up of multiple segments.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks so much!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2023 19:46:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1311718#M1035</guid>
      <dc:creator>BigLouC</dc:creator>
      <dc:date>2023-07-25T19:46:00Z</dc:date>
    </item>
  </channel>
</rss>

