Fill hole in polygon

1135
8
03-01-2022 12:02 AM
DavidMrázek
Occasional Contributor II

Hi,
I'm trying to find and fill holes in polygons.

This is how I look for holes:

 

private async Task EditHole(FeatureLayer polygonLayer, QueryFilter queryFilter)
        {
            await QueuedTask.Run(() =>
            {
                var list = new List<Polygon>();
                ReadOnlySegmentCollection seg = null;
                var polygonFeatureClass = polygonLayer.GetTable() as FeatureClass;
                var polygonDefinition = polygonFeatureClass.GetDefinition();
                var rowCursor = polygonFeatureClass.Search(queryFilter);
                while (rowCursor.MoveNext())
                {
                    using (var lineFeature = rowCursor.Current as Feature)
                    {
                        var polygonGeometry = lineFeature.GetShape() as Polygon;
                        IEnumerator<ReadOnlySegmentCollection> segments = polygonGeometry.Parts.GetEnumerator();
                        while (segments.MoveNext())
                        {
                            //I do not know what to do
                           
                        }
                    }
                }
               
            });
        }

 

 

For example, a polygon like this:

polygon with holes.png

 

Would anyone have an idea or advice on how to do this?

Is there any way to distinguish between the outer and inner polygon?

 

Thank you for any advice and help

David

0 Kudos
8 Replies
DanPatterson
MVP Esteemed Contributor

the outer ring should be the first part, the inner rings follow for singlepart shapes with holes

or an oft used method is to calculate the area for the bits using the "shoelace formula"... clockwise oriented outer rings yield a negative area and ccw inner rings yield a positive area


... sort of retired...
0 Kudos
DavidMrázek
Occasional Contributor II

When the mentioned selection creates over 180 thousand parts, then I can distinguish external and internal how?

0 Kudos
DanPatterson
MVP Esteemed Contributor

Using Pro tools

Eliminate Polygon Part (Data Management)—ArcGIS Pro | Documentation

But this seems to be a programming language specific question and not an ArcGIS Pro question.  Is there an SDK that you want it moved to?


... sort of retired...
0 Kudos
DavidMrázek
Occasional Contributor II

Surely this is a question rather there, how is it moved?

0 Kudos
DanPatterson
MVP Esteemed Contributor

given the proliferation of curly braces, I moved it to the arcgis-api-for-javascript question section.

You choose your Community from the following to get a targeted location

communities.png

moderators can do the moves


... sort of retired...
DavidMrázek
Occasional Contributor II

ArcGIS Pro SDK, c # language is not on the menu so it will be the best there

0 Kudos
CharlesMacleod
Esri Regular Contributor
DavidMrázek
Occasional Contributor II

Thank you for helping to make the next move.

0 Kudos