in_fc = r"C:\arcpro_npg\npg\Project_npg\tests.gdb\sq2"
with SearchCursor(in_fc, "SHAPE@") as cursor:
a = [row[0] for row in cursor]
a
Out[16]:
[<Polygon object at 0x1759a6c8348[0x1759a6b7ba0]>,
<Polygon object at 0x1759a6c82c8[0x1759a6b7bd0]>,
<Polygon object at 0x1759a6c8548[0x1759a6b7c30]>,
<Polygon object at 0x1759a6c8a48[0x1759a6b7a80]>,
<Polygon object at 0x1759a6c8148[0x1759a6b7cc0]>,
<Polygon object at 0x1759a6c8cc8[0x1759a6b7ae0]>,
<Polygon object at 0x1759a6c8848[0x1759a6b7b10]>]
a[0]
# image of shape
a[0][0]
<Array [<Point (300009.0, 5000001.0, #, #)>, <Point (300000.0, 5000000.0, #, #)>, <Point (300002.0, 5000008.0, #, #)>, <Point (300008.0, 5000010.0, #, #)>, <Point (300010.0, 5000010.0, #, #)>, <Point (300010.0, 5000008.0, #, #)>, <Point (300009.0, 5000001.0, #, #)>, None, <Point (300003.0, 5000003.0, #, #)>, <Point (300007.0, 5000003.0, #, #)>, <Point (300005.0, 5000007.0, #, #)>, <Point (300003.0, 5000003.0, #, #)>]>
a[0][0][0]
<Point (300009.0, 5000001.0, #, #)>
The simplest is to use methods on the cursor directly,
def _fc_as_narray_(in_fc, with_id=True):
"""Return geometry from a featureclass using `as_narray`."""
flds = ["SHAPE@X", "SHAPE@Y"]
if with_id:
flds = ["OID@", "SHAPE@X", "SHAPE@Y"]
with SearchCursor(in_fc, flds, explode_to_points=True) as cursor:
a = cursor._as_narray()
del cursor
return a
a = _fc_as_narray_(in_fc, True)
a0 = list(a) # --- convert to list
a0
[(1, 300009.00, 5000001.00),
(1, 300000.00, 5000000.00),
(1, 300002.00, 5000008.00),
(1, 300008.00, 5000010.00),
(1, 300010.00, 5000010.00),
(1, 300010.00, 5000008.00),
(1, 300009.00, 5000001.00),
(1, 300003.00, 5000003.00),
(1, 300007.00, 5000003.00),
(1, 300005.00, 5000007.00),
(1, 300003.00, 5000003.00),
(2, 300010.00, 5000008.00),
(2, 300010.00, 5000010.00),
(2, 300008.00, 5000010.00),
(2, 300008.00, 5000011.00),
(2, 300008.00, 5000012.00),
(2, 300012.00, 5000012.00),
(2, 300012.00, 5000008.00),
(2, 300010.00, 5000008.00),
(3, 300008.00, 5000011.00),
(3, 300005.00, 5000010.00),
(3, 300005.00, 5000012.00),
(3, 300006.00, 5000012.00),
(3, 300008.00, 5000012.00),
(3, 300008.00, 5000011.00),
(4, 300006.00, 5000012.00),
(4, 300005.00, 5000012.00),
(4, 300005.00, 5000015.00),
(4, 300007.00, 5000014.00),
(4, 300006.00, 5000012.00),
(5, 300002.50, 5000013.00),
(5, 300001.00, 5000011.50),
(5, 300000.00, 5000010.00),
(5, 300001.00, 5000013.00),
(5, 300003.00, 5000014.00),
(5, 300002.50, 5000013.00),
(5, 300001.00, 5000012.50),
(5, 300001.50, 5000012.50),
(5, 300001.50, 5000013.00),
(5, 300001.00, 5000012.50),
(6, 300004.00, 5000012.50),
(6, 300003.00, 5000011.00),
(6, 300002.00, 5000011.00),
(6, 300001.00, 5000011.50),
(6, 300002.50, 5000013.00),
(6, 300004.00, 5000012.50),
(6, 300002.50, 5000012.50),
(6, 300001.50, 5000011.50),
(6, 300002.50, 5000011.50),
(6, 300002.50, 5000012.50),
(9, 300002.00, 5000011.00),
(9, 300003.00, 5000011.00),
(9, 300004.00, 5000009.00),
(9, 300002.00, 5000009.00),
(9, 300002.00, 5000011.00)]
... sort of retired...