I have a problem when inserting features with polygon feature class in FGDB. This is my code:

    ... initialising some fields (does not affect performance)
    m_featureBuffer.Shape = CreateShape(feature);


    protected override ESRI.ArcGIS.Geometry.IGeometry CreateShape(IAbstractFeature feature)
        IArea area = (IArea)feature;

        ESRI.ArcGIS.Geometry.IPointCollection polygon = new ESRI.ArcGIS.Geometry.PolygonClass();
        foreach (Point2D point2d in area.Polygon.OuterBoundaryIs.Coordinates)
            ESRI.ArcGIS.Geometry.IPoint point = new ESRI.ArcGIS.Geometry.PointClass();
            point.PutCoords(point2d.X, point2d.Y);
        return (ESRI.ArcGIS.Geometry.IGeometry)polygon;

In this case inserting ~1500 polygons takes about ~110 seconds. If I comment this line

m_featureBuffer.Shape = CreateShape(feature);

the insert takes ~10 seconds! If I create empty polygons and pass them in the Shape property of the feature buffer, it takes ~10 seconds too.

I tried to use the IFeatureClassLoad according to the ESRI example, but it doesn't help with the performance.

  • What's the purpose of the CreateShape function? Are you constructing new polygons from outer boundaries of the incoming polygons? Looks like you have to loop through potentially an unknown number of vertices depending on the polygon size and complexity and construct a new polygon from individual vertices. I think this is the slow part. Have you considered constructing the geometry you want from polygon rings instead of vertices? Sep 17, 2012 at 2:26
  • I have array of points as input. I tried construct rings from them and pass to AddGeometry method of IGeometryCollection interface of polygon, but it didn't help.
    – Maxim
    Sep 17, 2012 at 2:32
  • Why points? Do you need to do on such a low level? Why not just iterate through the polygon rings and use the one you want? Sep 17, 2012 at 2:39
  • 1
    Ok, I'll try to explain you. I have an XML-file which I need to parse and to construct features from data that presented in this file. For polygons - data is an array of points of outer and inner boundaries. I haven't rings. I have points.
    – Maxim
    Sep 17, 2012 at 2:47
  • Regarding your latest edit, please post your solution as an answer for the benefit of other readers.
    – blah238
    Sep 17, 2012 at 4:53

1 Answer 1


Solution (from ESRI example):

public void CreatePolygonByPoints()
    IGeometryBridge2 geometryBridge2 = new GeometryEnvironmentClass();
    IPointCollection4 pointCollection4 = new PolygonClass();

    // aWKSPointBuffer - array of WKSPoint structures (input points in my case)
    // WKSPoint[] aWKSPointBuffer;
    geometryBridge2.SetWKSPoints(pointCollection4, ref aWKSPointBuffer);

In my case I create rings for outer and inner boundaries by this method and then add them to the polygon by AddGeometry method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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