<?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: Aggregate Polygons seems to be creating an invalid geometry in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150316#M63933</link>
    <description>&lt;P&gt;No, it came back without any outputs and nothing in the table.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2022 19:16:46 GMT</pubDate>
    <dc:creator>williamwinner</dc:creator>
    <dc:date>2022-03-03T19:16:46Z</dc:date>
    <item>
      <title>Aggregate Polygons seems to be creating an invalid geometry</title>
      <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150291#M63929</link>
      <description>&lt;P&gt;I'm running a script that takes a raster file and creates depth areas from it.&amp;nbsp; The process involves a number of tools including Aggregate Polygons.&lt;/P&gt;&lt;P&gt;It is this tool that seems to be causing me problems.&amp;nbsp; After I run this tool, I'm running a custom script to reduce the number of vertices but when the script runs, one of the holes in a feature seems to be completely missing.&amp;nbsp; (I've run this on dozens of rasters dozens of times and only had this one feature out of thousands have a problem.)&lt;/P&gt;&lt;P&gt;When I process the file, the end result is always missing a very large hole.&amp;nbsp; So, I've investigated by exporting all of the feature vertices to points.&amp;nbsp; There are 260,381 vertices in the feature.&amp;nbsp; But, when I run the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;cursor = arcpy.da.SearchCursor(inFile, ["SHAPE@"])

for feat in cursor:
    arcpy.AddMessage("part count=" + str(feat[0].partCount))
    parts = feat[0].getPart()

    for part in parts:
        arcpy.AddMessage("  -" + str(part.count))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it returns:&lt;/P&gt;&lt;PRE&gt;part count=1&lt;BR /&gt;-205085&lt;/PRE&gt;&lt;P&gt;I converted the feature to lines and then exported just the missing hole and it has 55,313 vertices.&amp;nbsp; There should be 18 holes in the feature.&amp;nbsp; Without that hole, I would expect to find 205,085 points in the feature (205,068 + 17 null points indicating the start of an inner ring).&lt;/P&gt;&lt;P&gt;So, why is the shape geometry not finding all of the points?&amp;nbsp; When I export it to it's vertices, it finds them all but when I run the above code, it misses an entire hole.&amp;nbsp; And repair geometry doesn't fix it.&amp;nbsp; After, it still shows one part with 205,085 vertices.&amp;nbsp; But, when I open it in ArcMap, it shows the hole fine.&lt;/P&gt;&lt;P&gt;I'm at a loss to figure out how to see this particular hole.&amp;nbsp; I can't fix the problem if I can't figure out how to find it.&lt;/P&gt;&lt;P&gt;Any suggestions?&amp;nbsp; I've tried everything I can think of to get the data out.&amp;nbsp; I've even tried exporting to JSON and then back from JSON but it has a problem parsing the JSON file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UPDATE:&lt;/P&gt;&lt;P&gt;I just tried to take the raw input from a SearchCursor and output it to an InsertCursor and the hole also disappears.&amp;nbsp; I've also submitted a Bug Report because it seems like the Aggregate Polygons tool has broken this feature.&amp;nbsp; Here's the code I just ran:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os

inFile = arcpy.GetParameterAsText(0)
outFile = arcpy.GetParameterAsText(1)
path, name = os.path.split(outFile)
arcpy.AddMessage(path + "\\" + name)
arcpy.CreateFeatureclass_management(path, name, "POLYGON", spatial_reference=arcpy.Describe(inFile).spatialReference)

cursor = arcpy.da.SearchCursor(inFile, ["SHAPE@"])
outputCursor = arcpy.da.InsertCursor(outFile, ["SHAPE@"])
for feat in cursor:
    arcpy.AddMessage("part count=" + str(feat[0].partCount))
    parts = feat[0].getPart()

    outputCursor.insertRow([arcpy.Polygon(parts)])

    arcpy.AddMessage(str(parts.count))
    for part in parts:
        arcpy.AddMessage("  -" + str(part.count))

del cursor, outputCursor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The feature went from:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="williamwinner_0-1646337675340.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35515i5EC6A7CD2C6BCDC5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="williamwinner_0-1646337675340.png" alt="williamwinner_0-1646337675340.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;to:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="williamwinner_1-1646337698750.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35516iC87F3568FCD12A40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="williamwinner_1-1646337698750.png" alt="williamwinner_1-1646337698750.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 20:02:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150291#M63929</guid>
      <dc:creator>williamwinner</dc:creator>
      <dc:date>2022-03-03T20:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Polygons seems to be creating an invalid geometry</title>
      <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150305#M63932</link>
      <description>&lt;P&gt;Check Geometry? any reports from it?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/check-geometry.htm" target="_blank"&gt;Check Geometry (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 19:06:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150305#M63932</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-03-03T19:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Polygons seems to be creating an invalid geometry</title>
      <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150316#M63933</link>
      <description>&lt;P&gt;No, it came back without any outputs and nothing in the table.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 19:16:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150316#M63933</guid>
      <dc:creator>williamwinner</dc:creator>
      <dc:date>2022-03-03T19:16:46Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Polygons seems to be creating an invalid geometry</title>
      <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150511#M63941</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bad_sp.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35553iE72907DED328AC02/image-size/large?v=v2&amp;amp;px=999" role="button" title="bad_sp.png" alt="bad_sp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This is the shapefile in a geodatabase, 260381 vertices, 1 part, 18 holes and 0 curves&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bad_sp2.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/35554i7349264C125AC2AA/image-size/large?v=v2&amp;amp;px=999" role="button" title="bad_sp2.png" alt="bad_sp2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;of course, the channel isn't closed at either end, perhaps due to a conversion or clipping artifact&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 01:47:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150511#M63941</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-03-04T01:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Aggregate Polygons seems to be creating an invalid geometry</title>
      <link>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150617#M63947</link>
      <description>&lt;P&gt;I've worked on it in both a GDB and the in_memory workspace.&amp;nbsp; My larger script uses the in_memory workspace to create temporary feature classes.&amp;nbsp; But, during de-bugging, I've been running through the script step by step and storing everything in a GDB.&amp;nbsp; I have the same issues whether in the GDB or not.&amp;nbsp; I haven't tried it in ArcPro yet as we're only starting to switch over and the script needs to work in ArcMap.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Mar 2022 12:31:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/aggregate-polygons-seems-to-be-creating-an-invalid/m-p/1150617#M63947</guid>
      <dc:creator>williamwinner</dc:creator>
      <dc:date>2022-03-04T12:31:03Z</dc:date>
    </item>
  </channel>
</rss>

