Can't figure out how to insert a polygon object into a feature class

221
2
Jump to solution
11-17-2021 03:51 PM
ChrisCowin
New Contributor III

Hello,

I've been struggling for two days trying to figure out how to insert a polygon object into a feature class. I've written the following code based off the Writing Geometries guide, unfortunately all of those examples are starting from scratch and I extracted my polygon objects from the .getExtents().polygon function in the camera class. This creates the row and adds the name but there arent any of the polygons.

for name, poly in polyDict.items():
    with arcpy.da.InsertCursor(gdb_fc, ['Name', 'SHAPE@XY']) as cursor:
        cursor.insertRow([name, poly])

 

I've also tried adding an index to the poly variable to try the array but that doesn't work either. I'm obviously doing something wrong but have no idea as to what.

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

confirm you have a polygon object from the extent

you should be using "SHAPE@" instead... you should read down further in the help files.

The polygon class you can get the extent and you can create the geometry from examples in the second link

Polygon—ArcGIS Pro | Documentation

Write geometries—ArcGIS Pro | Documentation


... sort of retired...

View solution in original post

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

confirm you have a polygon object from the extent

you should be using "SHAPE@" instead... you should read down further in the help files.

The polygon class you can get the extent and you can create the geometry from examples in the second link

Polygon—ArcGIS Pro | Documentation

Write geometries—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos
ChrisCowin
New Contributor III

Figured it out if someone finds this later, Polygons need to be SHAPE@ and not SHAPE@XY.