Hi All,
I have thousands of buildings which few contains donuts, according to the customer requirement would like to remove donuts.
Hence, Kindly provide a solution how can i remove these donuts using .net program.
Thanks in Advance
Here is a Python function that does what you need:
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">fill_donut</SPAN><SPAN class="punctuation token">(</SPAN>in_lyr<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'''Edits a layer in-place and fills all donut holes or gaps in the selected features. Will operate on entire layer if there are no features selected. Requires layer to honor selected features. '''</SPAN> desc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>in_lyr<SPAN class="punctuation token">)</SPAN> shapefield <SPAN class="operator token">=</SPAN> desc<SPAN class="punctuation token">.</SPAN>ShapeFieldName rows <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>in_lyr<SPAN class="punctuation token">)</SPAN> n <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> polyGeo <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># to hold edited shape</SPAN> polyOuter <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># to hold outer ring</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> rows<SPAN class="punctuation token">:</SPAN> feat <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">.</SPAN>getValue<SPAN class="punctuation token">(</SPAN>shapefield<SPAN class="punctuation token">)</SPAN> qInterior <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">False</SPAN> <SPAN class="keyword token">for</SPAN> partNum <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>feat<SPAN class="punctuation token">.</SPAN>partCount<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">:</SPAN> part <SPAN class="operator token">=</SPAN> feat<SPAN class="punctuation token">.</SPAN>getPart<SPAN class="punctuation token">(</SPAN>partNum<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> pt <SPAN class="keyword token">in</SPAN> iter<SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">lambda</SPAN><SPAN class="punctuation token">:</SPAN>part<SPAN class="punctuation token">.</SPAN>next<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN>None<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># iter stops on null pt</SPAN> polyOuter<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>pt<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> part<SPAN class="punctuation token">.</SPAN>count <SPAN class="operator token">></SPAN> len<SPAN class="punctuation token">(</SPAN>polyOuter<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">:</SPAN> qInterior <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> polyGeo<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>polyOuter<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># reassemble each part</SPAN> polyOuter<SPAN class="punctuation token">.</SPAN>removeAll<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># ready for next part</SPAN> <SPAN class="keyword token">if</SPAN> qInterior <SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># in any part of this feature, otherwise skip update</SPAN> n<SPAN class="operator token">+=</SPAN><SPAN class="number token">1</SPAN> row<SPAN class="punctuation token">.</SPAN>setValue<SPAN class="punctuation token">(</SPAN>shapefield<SPAN class="punctuation token">,</SPAN>polyGeo<SPAN class="punctuation token">)</SPAN> rows<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN> polyGeo<SPAN class="punctuation token">.</SPAN>removeAll<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">del</SPAN> rows<SPAN class="punctuation token">,</SPAN>row msg <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Features with interior ring filled "</SPAN><SPAN class="operator token">+</SPAN>str<SPAN class="punctuation token">(</SPAN>n<SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>msg<SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>RefreshActiveView<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I think Joshua Bixby has the right idea. Take a look at "IPolygon4.ExteriorRingBag" which creates and returns a geometrybag that contains references to all exterior rings. You can take this and create a polygon with it and the donuts won't exist.
Yep, IPolygon.FindExteriorRings is the method.
If you want to use geoprocessing or python you can also use the Eliminate Polygon Part tool.
A haven't done .NET programming in years, well, years and years. Although I can't offer you specific objects and functions, I can say that polygons are made up of a series of linear rings. If you can find and extract the exterior ring, you can create a polygon using it, and the donuts won't exist. Or, you could try to remove the interior linear rings. I am not sure which would be easier.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.