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))

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):

enter image description here

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?

2 Answers 2


You should always specify the SpatialReference at the time of feature class creation, because the Esri spatial reference encompasses much more than just the coordinate reference -- It also imparts resolution and tolerance information appropriate to that coordinate reference. The default SR just assumes Cartesian meters, so just applying the coordinate reference afterward preserves the default "millimeter" XY Units, which collapses the vertices to a 0.001 degree grid (vice the 0.000000001 degree resolution initially set with a geographic coordinate reference).

Also, you should always retrieve the SpatialReference from the target feature class to apply to the arcpy.FromWKT() helper function (or any other Geometry constructor), so that the spatial reference isn't silently transformed when the row is actually inserted.

        gdbfile, fc, "POLYGON", 
sr = arcpy.Describe(os.path.join(gdbfile,fc)).spatialReference

        shape_insert = arcpy.FromWKT(rowValue["wkts"][0], sr)

See the Understanding Coordinate Management in the Geodatabase whitepaper for details on the characteristics of a SpatialReference.

  • That works - thanks for the reference as well.
    – ArcPie_22
    Nov 18, 2022 at 17:18

Seeing that only geometries are being created, and not attributed, when inserted into a new feature class, a simpler way to approach this would be to create a Python list of geometries and then just copy them all into a new feature class at the end:

fc = "Test"
fc_path = gdbfile + "\\Test"
SR = arcpy.SpatialReference(4269)

geoms = [
    arcpy.FromWKT(rowValue["wkts"][0], SR)
    for rowValue
    in polygonIncidents
arcpy.management.CopyFeatures(geoms, fc_path)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.