ArcMap 10.8.1 /Python 2.7
I'm reading all the vertices of polygon Shapefiles (some polygons are multipart crossing 180 and some are not perfect square/rectangle) using the code below. 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?
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 > 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)
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. 