Polygon with a hole in it

I have a polygon IPolygon4 with a hole in it, as you can see. How can I get rid of the donut hole, and have the whole thing be one simple polygon with 5 vertices.

Here are the constructed WKT points, I projected to GCS_WGS_1984 so it would be more readable.

MULTIPOLYGON (((-93.948870475981934 46.388792874272333, -94.07064721379696 46.3298500944495, -94.292075670722767 46.511771884217374, -94.285856486919386 46.334338634913607, -94.043790864983947 46.2678965446348, -93.96530675201366 46.327504695188082, -93.948870475981934 46.388792874272333)), ((-93.948870475981934 46.388792874272333, -93.914198248635017 46.517621156043539, -94.292075670722767 46.511771884217374, -93.948870475981934 46.388792874272333)))


2 Answers 2


Given that the polygon is simple, and the hole is an interior ring, you can create a new polygon using the IPolygon4.ExteriorRingBag property, and replace the current geometry with the exterior ring (or rings in case of MultiPolygon).

Otherwise, if the polygon is a "spaghetti-polygon", where the holes is caused by exterior ring is messed up (no interior ring), you probably have to do a manual edit (e.g. using sketch properties).

EDIT: (After you updated your question with WKT) The problem is that the geometry is NOT a donut polygon, it is a multipolygon. Therefore, you get two exterior rings in ExteriorRingBag instead of one. If the user wants to construct a polygon with a hole in ArcGis, the "Cut Polygon" tool must be used.

Here is a screenshot showing both polygon rings in your geometry:

enter image description here

Assuming that you are using ArcGis, here is the way to construct a donut properly: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001t0000003q000000.htm

  • ExteriorRingBag gives me a top polygon and a bottom polygon. I can't do it manually because the use case is that the user will construct the polygon.
    – patrick
    Aug 12, 2013 at 18:32
  • Your WKT shows the problem, see updated answer.
    – Oyvind
    Aug 13, 2013 at 7:58
    IPolygon ppolygon = pFeature.ShapeCopy as IPolygon;
    IGeometryCollection pgeomColl = ppolygon as IGeometryCollection;
    int x = pgeomColl.GeometryCount;
    for (int i = 0; i < x; i++)
       IGeometry pNewGeom = pgeomColl.get_Geometry(i);
       IFeatureBuffer featureBuffer = pFeatureClass.CreateFeatureBuffer();
       for (int k = 0; k <= pFeatureClass.Fields.FieldCount - 1; k++)
        if (pFeatureClass.Fields.get_Field(k).Editable &&   pFeatureClass.Fields.get_Field(k).Type != esriFieldType.esriFieldTypeGeometry)
  featureBuffer.set_Value(k, pFeature.get_Value(k));

  IGeometryCollection icollection = null;
  if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
      icollection = new PolylineClass();
  else if (pFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
      icollection = new PolygonClass();

   icollection.AddGeometry(pNewGeom, ref miss, ref miss);

   IGeometry pgeomNew = (IGeometry)icollection;
   IZAware pZ1 = pFeature.Shape as IZAware;
   if (pZ1.ZAware)
    pZ1 = pgeomNew as IZAware;
    pZ1.ZAware = true;
    pZ1 = pgeomNew as IZAware;
    pZ1.ZAware = false;
   featureBuffer.Shape = pgeomNew;
  • 1
    I think this Answer could do with you using the edit button to apply more formatting and also some descriptive text about how your code answers the Question.
    – PolyGeo
    Dec 12, 2013 at 7:36

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.