Skip to main content
2 of 4
added 534 characters in body
Bera
  • 77.8k
  • 14
  • 78
  • 188

A bit unclear what you want but you should be able to use collections.defaultdict:

Using list as the default_factory, it is easy to group a sequence of key-value pairs into a dictionary of lists

import arcpy
from collections import defaultdict
fc = r"C:\folder\shapefile.shp"
dx = defaultdict(list)
dy = defaultdict(list)

with arcpy.da.SearchCursor(fc,['OID@','SHAPE@']) as cursor:
    for row in cursor:
        array1=row[1].getPart()
        for vertice in range(row[1].pointCount):
            pnt=array1.getObject(0).getObject(vertice)
            dx[row[0]].append(pnt.X)
            dy[row[0]].append(pnt.Y)

You will now have two dictionaries with all x and y values and ObjectID as keys. For example all the vertices for the first polygon (objectid 0) as lists:

print(dx[0])
print(dy[0])
>>[800000.0, 800000.0, 700000.0, 700000.0, 800000.0]
>>[7400000.0, 7300000.0, 7300000.0, 7400000.0, 7400000.0]

Start and end coordinates are the same. Can be removed if you want.

Bera
  • 77.8k
  • 14
  • 78
  • 188