I'm trying to add new features to a layer based on geometries created from a list of WKTs. The code I have so far:
- Creates a polygon layer and sets the projection (NAD83)
- Creates a geometry object (polygon) from using a well-known text (WKT) value, while using the same projection
- Inserts the geometry into the polygon layer in the SHAPE* field
fc = "Test"
fc_path = gdbfile + "\\Test"
arcpy.CreateFeatureclass_management(gdbfile, fc, "POLYGON", "", "DISABLED", "DISABLED", "", "", "0", "0", "0")
arcpy.management.DefineProjection(fc_path, "GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
with arcpy.da.InsertCursor(fc_path, ["SHAPE@"]) as cur:
for rowValue in polygonIncidents:
shape_insert = arcpy.FromWKT(rowValue["wkts"][0], arcpy.SpatialReference(4269))
cur.insertRow([shape_insert])
Everything is working as intended up until the row is inserted. The shape insert object has the expected coordinates for the polygon (blue pins below), but when the row is inserted it ends up as a line in the layer (black line below):
If I copy the geometry objects to a new layer using arcpy.Copy_management, everything works as intended - however I need a solution for an existing layer.
The issue seems to be happening somewhere in the insert cursor. Is there a reason the current code is not working? Is there another way to insert rows into an existing layer?