<?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: Polygon creation tool in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116257#M47762</link>
    <description>&lt;P&gt;Thank you. Creating a polygon is no problem.&lt;/P&gt;</description>
    <pubDate>Fri, 12 Nov 2021 10:36:28 GMT</pubDate>
    <dc:creator>DavidMrázek</dc:creator>
    <dc:date>2021-11-12T10:36:28Z</dc:date>
    <item>
      <title>Polygon creation tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116233#M47758</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I would like to create a tool that finds a hole in a polygon and then loads it into a new layer as a new polygon. Has anyone had a similar project? Somehow I don't know how to start.&lt;/P&gt;&lt;P&gt;With the code written below, I can create a polygon in which the holes are located, but I don't know how to write them to create those holes.&lt;/P&gt;&lt;P&gt;I will be happy for any advice, idea or solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; protected override async void OnClick()
        {
            var polylineFeatureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(lyr =&amp;gt; lyr.ShapeType == esriGeometryType.esriGeometryPolyline);

            if (polylineFeatureLayer == null)
                return;
            await CreateFcWithAttributesAsync("Polygon", EnumFeatureClassType.POLYGON);

            var polygonFeatureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault(lyr =&amp;gt; lyr.ShapeType == esriGeometryType.esriGeometryPolygon);

            if (polygonFeatureLayer == null)
                return;

            await ConstructSamplePolygon(polygonFeatureLayer, polylineFeatureLayer);
        }
        private Task&amp;lt;bool&amp;gt; ConstructSamplePolygon(FeatureLayer polygonLayer, FeatureLayer lineLayer)
        {

            return QueuedTask.Run(() =&amp;gt;
            {
                var polygonFeatureClass = polygonLayer.GetTable() as FeatureClass;
                var polygonDefinition = polygonFeatureClass.GetDefinition();
                var lineFeatureClass = lineLayer.GetTable() as FeatureClass;

                var lineCursor = lineFeatureClass.Search(null, false);

                var createOperation = new EditOperation()
                {
                    Name = "Vytvořit polygon",
                    SelectNewFeatures = false
                };

                while (lineCursor.MoveNext())
                {
                    using (var lineFeature = lineCursor.Current as Feature)
                    {
                        var polylineGeometry = lineFeature.GetShape() as Polyline;
                        ReadOnlyPointCollection pts = polylineGeometry.Points;
                        // var polygonBuilder = PolygonBuilder.CreatePolygon(pts, polygonDefinition.GetSpatialReference());
                        List&amp;lt;MapPoint&amp;gt; lineMapPoints = new List&amp;lt;MapPoint&amp;gt;();
                        lineMapPoints.AddRange(pts);
                        var newPolygon =
                            PolygonBuilder.CreatePolygon(lineMapPoints, polygonDefinition.GetSpatialReference());
                        createOperation.Create(polygonLayer, newPolygon);
                    }
                }

                return createOperation.ExecuteAsync();
            });
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;BR /&gt;David&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 07:59:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116233#M47758</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-11-15T07:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Polygon creation tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116254#M47761</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/a-quick-tour-of-creating-tools-in-python.htm" target="_blank"&gt;A quick tour of creating tools with Python—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;holes will make the shape multipart&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/polygon.htm" target="_blank"&gt;Polygon—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/reading-geometries.htm" target="_blank"&gt;Read geometries—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;if you find holes, then the order of the points needs to be reversed&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 10:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116254#M47761</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-12T10:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Polygon creation tool</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116257#M47762</link>
      <description>&lt;P&gt;Thank you. Creating a polygon is no problem.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 10:36:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/polygon-creation-tool/m-p/1116257#M47762</guid>
      <dc:creator>DavidMrázek</dc:creator>
      <dc:date>2021-11-12T10:36:28Z</dc:date>
    </item>
  </channel>
</rss>

