<?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 Order of polygon vertices returned by SearchCursor in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108811#M62680</link>
    <description>&lt;P&gt;ArcMap 10.8.1 /Python 2.7&lt;/P&gt;&lt;P&gt;I'm reading all the vertices of&amp;nbsp; polygon Shapefiles (&lt;STRONG&gt;some&amp;nbsp;polygons are multipart crossing 180 and some are not perfect square/rectangle&lt;/STRONG&gt;) using the code below.&amp;nbsp;But the order of the vertices read in the code is different each time with every Shapefile, sometimes SW corner is returned first and sometimes NW. Is this true that the vertices will be traversed by SearchCursor in random order or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;polygon_vertices = []
        for row in arcpy.da.SearchCursor(self.feature_class, ["OID@", 'SHAPE@']):
            vertices = [row[0]]
            try:
                for part in row[1]:
                    for point in part:
                        if point:
                            vertex = (point.X, point.Y)
                            if vertex not in vertices:
                                vertices.append(vertex)
                        else:
                            print('Inner ring')
                # check for 180 crossings and change NW, NE values
                if row[1].partCount &amp;gt; 1:
                    ordered_vertices = self.order_vertices(vertices, row[1].extent.XMin, row[1].extent.XMax)
                    polygon_vertices.append(ordered_vertices)
                else:
                    polygon_vertices.append(vertices)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For perfect square/rectangle polgon Shapefiles, I was able to get the vertices from Extent ( except for multiparts) but have to traverse the vertices for irregular polygons as shown below.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ss2424_0-1634651883151.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25524iC66096FFAF325F44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ss2424_0-1634651883151.png" alt="ss2424_0-1634651883151.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Oct 2021 14:29:44 GMT</pubDate>
    <dc:creator>ss2424</dc:creator>
    <dc:date>2021-10-19T14:29:44Z</dc:date>
    <item>
      <title>Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108811#M62680</link>
      <description>&lt;P&gt;ArcMap 10.8.1 /Python 2.7&lt;/P&gt;&lt;P&gt;I'm reading all the vertices of&amp;nbsp; polygon Shapefiles (&lt;STRONG&gt;some&amp;nbsp;polygons are multipart crossing 180 and some are not perfect square/rectangle&lt;/STRONG&gt;) using the code below.&amp;nbsp;But the order of the vertices read in the code is different each time with every Shapefile, sometimes SW corner is returned first and sometimes NW. Is this true that the vertices will be traversed by SearchCursor in random order or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;polygon_vertices = []
        for row in arcpy.da.SearchCursor(self.feature_class, ["OID@", 'SHAPE@']):
            vertices = [row[0]]
            try:
                for part in row[1]:
                    for point in part:
                        if point:
                            vertex = (point.X, point.Y)
                            if vertex not in vertices:
                                vertices.append(vertex)
                        else:
                            print('Inner ring')
                # check for 180 crossings and change NW, NE values
                if row[1].partCount &amp;gt; 1:
                    ordered_vertices = self.order_vertices(vertices, row[1].extent.XMin, row[1].extent.XMax)
                    polygon_vertices.append(ordered_vertices)
                else:
                    polygon_vertices.append(vertices)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For perfect square/rectangle polgon Shapefiles, I was able to get the vertices from Extent ( except for multiparts) but have to traverse the vertices for irregular polygons as shown below.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ss2424_0-1634651883151.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25524iC66096FFAF325F44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ss2424_0-1634651883151.png" alt="ss2424_0-1634651883151.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:29:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108811#M62680</guid>
      <dc:creator>ss2424</dc:creator>
      <dc:date>2021-10-19T14:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108812#M62681</link>
      <description>&lt;P&gt;It's always been a mystery to me; I thought at one time it was by ascending value in ObjectID.&amp;nbsp; Seems like friend and colleague&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1371"&gt;@JoshuaBixby&lt;/a&gt;&amp;nbsp;provided an explanation at one time...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:09:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108812#M62681</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-10-19T14:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108815#M62682</link>
      <description>&lt;P&gt;Seems like Extent of polygons are always returned in one order but its not clear which order the vertices are read...is it possible to force it to read one particular vertex and then traverse clockwise?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:16:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108815#M62682</guid>
      <dc:creator>ss2424</dc:creator>
      <dc:date>2021-10-19T14:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108819#M62683</link>
      <description>&lt;P&gt;Clockwise?&amp;nbsp; Beats me!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 14:20:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108819#M62683</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-10-19T14:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108847#M62687</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1371"&gt;@JoshuaBixby&lt;/a&gt;&amp;nbsp; I'm&amp;nbsp; searching for your post to find a response but no luck yet.. Can u help?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 15:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108847#M62687</guid>
      <dc:creator>ss2424</dc:creator>
      <dc:date>2021-10-19T15:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108857#M62689</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1371"&gt;@JoshuaBixby&lt;/a&gt;&amp;nbsp;has hundreds if not thousands of posts; it may have been a older discussion we had before this forum was in place...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Oct 2021 15:24:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1108857#M62689</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-10-19T15:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109401#M62719</link>
      <description>&lt;P&gt;Seeing you are working with multiple polygons in multiple shapefiles, it is best to start isolating the issue by isolating the data.&amp;nbsp; What happens if you take a single polygon from a single shapefile and run it many times, do you see different results?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109401#M62719</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-10-20T19:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109427#M62720</link>
      <description>&lt;P&gt;I exported a single polygon from each of 2 different Shapefiles and I saw consistent&amp;nbsp; results. The firstPoint returned for a polygon in Shapefile 1 is SE corner while the other polygon from Shapefile 2 returned SW corner first.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 20:01:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109427#M62720</guid>
      <dc:creator>ss2424</dc:creator>
      <dc:date>2021-10-20T20:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109490#M62723</link>
      <description>&lt;P&gt;Is that what you are perceiving to be the inconsistency, the fact that one polygon starts in the SE corner while the other starts in the SW corner?&amp;nbsp; The order of the vertices is determined when a shape is created, not when a shape is read, so the source shapefiles are not following a consistent rule with building polygons.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 22:25:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109490#M62723</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-10-20T22:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: Order of polygon vertices returned by SearchCursor</title>
      <link>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109497#M62724</link>
      <description>&lt;P&gt;Thanks for confirming..I modified the code to get the&amp;nbsp; extent of the polygon and then get the 4 corners from extent...though I'm seeing expected results I want to make sure I can go this way than getting the vertices using my code above(originally posted) or is there an advantage of one method over another?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 22:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/order-of-polygon-vertices-returned-by-searchcursor/m-p/1109497#M62724</guid>
      <dc:creator>ss2424</dc:creator>
      <dc:date>2021-10-20T22:52:58Z</dc:date>
    </item>
  </channel>
</rss>

