<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How split multi-part polygons, and keep holes, without geoprocessing tools? in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369558#M20629</link>
    <description>&lt;P&gt;It is mostly there, you just need to do geomColl.AddGeometry on all of the interior rings of your original polygon.&amp;nbsp; I am fairly certain that any interior rings not in your exterior ring will be ignored.&amp;nbsp; However, if not, you might have to run an intersect first to see.&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;P&gt;Brent&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 14:31:41 GMT</pubDate>
    <dc:creator>BrentHoskisson</dc:creator>
    <dc:date>2024-01-12T14:31:41Z</dc:date>
    <item>
      <title>How split multi-part polygons, and keep holes, without geoprocessing tools?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369483#M20628</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to loop over the features in a feature class and split each mulit-part polygon into single-part polygons. I don't want to use any geoprocessing tools. The problem is that the code below gives me each polygon part, but without the holes. I want to split the multi-part polygons but keep any polygon holes. Any ideas?&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;IFeatureClass inFc = // Input feature class&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;IFeatureClass outFc = // Ouput feature class&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;IFeature ftr;&lt;/DIV&gt;&lt;DIV&gt;IFeatureCursor cur = inFc.Search(null, true);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;while ((ftr = cur.NextFeature()) != null)&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;// Get spatial reference from orginal feature&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;ISpatialReference spRef = ftr.ShapeCopy.SpatialReference;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;object obj = Type.Missing;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;IGeometryBag geomBag = ((IPolygon4)ftr.ShapeCopy).ExteriorRingBag;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;IGeometryCollection coll = geomBag as IGeometryCollection;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;for (int i = 0; i &amp;lt; coll.GeometryCount; i++)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;IFeature newFtr = outFc.CreateFeature();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;IGeometryCollection geomColl = new PolygonClass();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;IGeometry geom = coll.get_Geometry(i);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;geom.SpatialReference = spRef;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;geomColl.AddGeometry(geom, ref obj, ref obj);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;geomColl.GeometriesChanged();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;IGeometry geom2 = (IPolygon)geomColl;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;newFtr.Shape = geom2;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;SPAN&gt;newFtr.Store();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Mikael&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 11:30:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369483#M20628</guid>
      <dc:creator>Mikael-J</dc:creator>
      <dc:date>2024-01-12T11:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: How split multi-part polygons, and keep holes, without geoprocessing tools?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369558#M20629</link>
      <description>&lt;P&gt;It is mostly there, you just need to do geomColl.AddGeometry on all of the interior rings of your original polygon.&amp;nbsp; I am fairly certain that any interior rings not in your exterior ring will be ignored.&amp;nbsp; However, if not, you might have to run an intersect first to see.&lt;/P&gt;&lt;P&gt;Good Luck&lt;/P&gt;&lt;P&gt;Brent&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 14:31:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369558#M20629</guid>
      <dc:creator>BrentHoskisson</dc:creator>
      <dc:date>2024-01-12T14:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: How split multi-part polygons, and keep holes, without geoprocessing tools?</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369564#M20630</link>
      <description>&lt;P&gt;Hi Brent!&lt;/P&gt;&lt;P&gt;You are so right. It's worked like a charm to add the interior rings as well.&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;/Mikael&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 14:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/how-split-multi-part-polygons-and-keep-holes/m-p/1369564#M20630</guid>
      <dc:creator>Mikael-J</dc:creator>
      <dc:date>2024-01-12T14:38:31Z</dc:date>
    </item>
  </channel>
</rss>

