<?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: Default Polygon Shape Length in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1421966#M45144</link>
    <description>&lt;P&gt;Thanks Johannes. I wonder if the scripts work for irregularly shaped polygons?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 May 2024 12:54:09 GMT</pubDate>
    <dc:creator>SiqingChen</dc:creator>
    <dc:date>2024-05-09T12:54:09Z</dc:date>
    <item>
      <title>Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1338311#M44742</link>
      <description>&lt;P&gt;Hi, I just discovered the shape length calculated for a polygon feature is the perimeter of the feature and not the feature length. Is this always the case or is there a way to make it so the shape length field automatically calculates and shows the feature length?&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2023 17:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1338311#M44742</guid>
      <dc:creator>ChristinaNeal</dc:creator>
      <dc:date>2023-10-16T17:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1338615#M44743</link>
      <description>&lt;P&gt;You can create a field that contains whatever you want to populate, but polygons don't have length, just (2D) perimeter.&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 14:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1338615#M44743</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2023-10-17T14:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1339291#M44745</link>
      <description>&lt;P&gt;Interesting problem.&lt;/P&gt;&lt;P&gt;But! Very doable with some scripting.&lt;/P&gt;&lt;P&gt;To test, I made three rectangles, aligned to grid (Tried testing on irregular shapes but I couldn't be certain of my results, there).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1697654459540.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83405i638B8355F3926699/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1697654459540.png" alt="AlfredBaldenweck_0-1697654459540.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(The one on the left)&lt;/P&gt;&lt;P&gt;From the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/editing/create-squares-and-rectangles.htm#:~:text=Click%20the%20Horizontal%20/%20Grid%20Aligned%20button" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Click the&amp;nbsp;&lt;SPAN class=""&gt;Horizontal / Grid Aligned&amp;nbsp;&lt;/SPAN&gt;button to constrain a rectangle orthogonal to the map's coordinates system or the&lt;A href="https://pro.arcgis.com/en/pro-app/3.1/help/editing/enable-the-editing-grid.htm" target="_blank" rel="noopener"&gt;grid for editing&lt;/A&gt;if it is turned on. This setting is available on the construction toolbar and on the context menu when you right-click the map.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My rectangles, from left to right:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;1000 m x 1000 m&lt;/LI&gt;&lt;LI&gt;500 m x 2000 m&lt;/LI&gt;&lt;LI&gt;750 m x 1500&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_3-1697654733131.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83406iE30B7DAFDA21F53C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_3-1697654733131.png" alt="AlfredBaldenweck_3-1697654733131.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I added two double fields to my feature class: ShapeLenEW for the horizontal length and ShapeLenNS for the vertical length.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_4-1697654794203.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83407i7D23D610D058F076/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_4-1697654794203.png" alt="AlfredBaldenweck_4-1697654794203.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I then pasted this code into the Python window and clicked Enter twice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx = arcpy.mp.ArcGISProject("Current")
mp = aprx.activeMap
# Whatever the name is of the layer you want to update
poly = mp.listLayers("poly")[0]

# Insert your Length(X) and Length(Y) fields
fields = ["ShapeLenEW", "ShapeLenNS"]
# Add SHAPE@ to front of list
fields.insert(0,"SHAPE@")
# Run cursor.
# Beware cursors honor selection, so if only one record is selected, 
#   only one gets updated.
with arcpy.da.UpdateCursor(poly, fields) as cursor:
    for row in cursor:
        ext= row[0].extent
        # X Field is Max X minus Min X, Y field ditto.
        row[1] = ext.XMax-ext.XMin
        row[2] = ext.YMax-ext.YMin
        cursor.updateRow(row)
print("Done")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_8-1697655317031.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83411iAE89DFAAA7CA1536/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_8-1697655317031.png" alt="AlfredBaldenweck_8-1697655317031.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_7-1697655293811.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83410i9CA8164A126F530B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_7-1697655293811.png" alt="AlfredBaldenweck_7-1697655293811.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After running, the table has to be manually refreshed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_9-1697655670198.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83415i035B5317A15887C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_9-1697655670198.png" alt="AlfredBaldenweck_9-1697655670198.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_5-1697654896353.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83408iE062EC59CBD5F993/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_5-1697654896353.png" alt="AlfredBaldenweck_5-1697654896353.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And hey, presto! We have the maximum lengths of our polygons.&lt;/P&gt;&lt;P&gt;Major caveat: This will not make any real sense if your data is in a geographic coordinate system. Make sure it's in a projected coordinate system or it'll give you your answer in degrees (?).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, fair warning, measuring these geodesically with the measure tool will add a little bit of extra length (.028%, in my case) to your measures.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_6-1697655214544.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/83409i3DF0E7C4B2CB0C2B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_6-1697655214544.png" alt="AlfredBaldenweck_6-1697655214544.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;The other thing, of course, to keep in mind, is that this will only give you the max lengths at 90° intervals- either straight up or straight to the side. I don't think there's a half-easy way to calculate at anything other than those, unless you want to use SHAPE@.hullrectangle&amp;nbsp;and calculate diagonally from corner to corner.&lt;/P&gt;&lt;P data-unlink="true"&gt;But even with that, if you had a rectangular feature rotated at like, 23°, you wouldn't be able to get the length of its longest side.&lt;/P&gt;&lt;P data-unlink="true"&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit, if you prefer field calculator:&lt;/P&gt;&lt;PRE&gt;!Shape!.extent.XMax- !Shape!.extent.XMin &lt;/PRE&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;!Shape!.extent.YMax- !Shape!.extent.YMin&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 19:07:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1339291#M44745</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-10-18T19:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1344006#M44755</link>
      <description>&lt;P&gt;Not sure if it meets your needs, but the post here by&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;are working for me with attribute rules.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2023 17:32:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1344006#M44755</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2023-10-31T17:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1348387#M44777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Is this always the case or is there a way to make it so the shape length field automatically calculates and shows the feature length?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;The Shape_Length field always shows the polygon's perimeter. Most areas represented by polygons are not regular shapes like rectangles, where the concepts of "length" and "width" make sense.&amp;nbsp;They are mostly irregular, so the perimeter is the only sensible choice for Shape_Length.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you want to calculate "Length" as "The longest side of this polygon", you can do it with code in Calculate Field.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Arcade (copied from my answer &lt;A href="https://community.esri.com/t5/attribute-rules-questions/calculate-longest-length-of-polygon/m-p/1238391" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&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;Python:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# LengthField = 
get_longest_side(!Shape!)

# Code Block
def get_longest_side(polygon):
    sr = polygon.spatialReference
    distances = []
    for p in range(polygon.partCount):
        ring = polygon.getPart(p)
        for i in range(1, len(ring)):
            c1 = ring.getObject(i-1)
            p1 = arcpy.PointGeometry(arcpy.Point(c1.X, c1.Y, c1.Z), spatial_reference=sr)
            c2 = ring.getObject(i)
            p2 = arcpy.PointGeometry(arcpy.Point(c2.X, c2.Y, c2.Z), spatial_reference=sr)
            distances.append(p1.distanceTo(p2))
    return max(distances)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can also do it in the Python Window:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.UpdateCursor("TestPolygons", ["SHAPE@", "DoubleField1"]) as cursor:
    for polygon, length in cursor:
        sr = polygon.spatialReference
        distances = []
        for ring in polygon:
            for i in range(1, len(ring)):
                p1 = arcpy.PointGeometry(arcpy.Point(ring[i-1].X, ring[i-1].Y, ring[i-1].Z))
                p2 = arcpy.PointGeometry(arcpy.Point(ring[i].X, ring[i].Y, ring[i].Z))
                distances.append(p1.distanceTo(p2))
        cursor.updateRow([polygon, max(distances)])&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 11 Nov 2023 16:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1348387#M44777</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-11-11T16:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Default Polygon Shape Length</title>
      <link>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1421966#M45144</link>
      <description>&lt;P&gt;Thanks Johannes. I wonder if the scripts work for irregularly shaped polygons?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 May 2024 12:54:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/default-polygon-shape-length/m-p/1421966#M45144</guid>
      <dc:creator>SiqingChen</dc:creator>
      <dc:date>2024-05-09T12:54:09Z</dc:date>
    </item>
  </channel>
</rss>

