<?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 Circle filling a polygon in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/circle-filling-a-polygon/m-p/1238734#M63111</link>
    <description>&lt;P&gt;For any given polygon in a feature class I would like to create the largest possible circle that fits within this polygon (see examples below); in case of the original polygon being a circle, the new circle would be identical to the original.&lt;/P&gt;&lt;P&gt;Is there a function in ArcGIS Pro to achieve this?&lt;/P&gt;&lt;P&gt;PS: the minimum bounding geometry tool can draw a minimum circle on the outside of each polygon (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/minimum-bounding-geometry.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/minimum-bounding-geometry.htm&lt;/A&gt;). I just need to achieve the circle within the polygon instead.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 15:50:36 GMT</pubDate>
    <dc:creator>teakplantation</dc:creator>
    <dc:date>2022-12-07T15:50:36Z</dc:date>
    <item>
      <title>Circle filling a polygon</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/circle-filling-a-polygon/m-p/1238734#M63111</link>
      <description>&lt;P&gt;For any given polygon in a feature class I would like to create the largest possible circle that fits within this polygon (see examples below); in case of the original polygon being a circle, the new circle would be identical to the original.&lt;/P&gt;&lt;P&gt;Is there a function in ArcGIS Pro to achieve this?&lt;/P&gt;&lt;P&gt;PS: the minimum bounding geometry tool can draw a minimum circle on the outside of each polygon (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/minimum-bounding-geometry.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/minimum-bounding-geometry.htm&lt;/A&gt;). I just need to achieve the circle within the polygon instead.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 15:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/circle-filling-a-polygon/m-p/1238734#M63111</guid>
      <dc:creator>teakplantation</dc:creator>
      <dc:date>2022-12-07T15:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Circle filling a polygon</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/circle-filling-a-polygon/m-p/1238776#M63115</link>
      <description>&lt;P&gt;AFAIK, there is no out of the box tool for that.&lt;/P&gt;&lt;P&gt;This thread lists a few algorithms the get an incircle:&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/4279478/largest-circle-inside-a-non-convex-polygon" target="_blank"&gt;algorithm - Largest circle inside a non-convex polygon - Stack Overflow&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I took one of the approaches:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;tesselate the polygon with a Voronoi diagram (Thiessen polygons in ArcGIS)&lt;/LI&gt;&lt;LI&gt;find the node with the greates distance to the polygon's border, that's the center of the incircle&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;def create_incircle(polygon):
    add = arcpy.env.addOutputsToMap
    arcpy.env.addOutputsToMap = False
    # densify polygon to get rid of curves, which only have 2 vertices
    polygon = polygon.densify("DISTANCE", 10, 1)
    # extract vertices into a point fc
    vertices = arcpy.management.CreateFeatureclass("memory", "vertices", "POINT", spatial_reference=polygon.spatialReference)
    with arcpy.da.InsertCursor(vertices, ["SHAPE@"]) as cursor:
        for part in polygon:
            for v in part:
                cursor.insertRow([v])
    # create Thiessen polygons
    thiessen = arcpy.analysis.CreateThiessenPolygons(vertices, "memory/thiessen")
    # intersect these with  themselves to get candidate points
    test_points = arcpy.analysis.Intersect([thiessen], "memory/TestPoints", output_type="POINT")
    # get the point inside the polygon with the greatest distance to the polygon's boundary
    candidates = []
    boundary = polygon.boundary()
    with arcpy.da.SearchCursor(test_points, ["SHAPE@"]) as cursor:
        for p, in cursor:
            if p.disjoint(polygon):
                continue
            candidates.append([p, p.distanceTo(boundary)])
    center = sorted(candidates, key=lambda c: c[1])[-1]
    # buffer that point ith the distance to the boundary, return
    arcpy.env.addOutputsToMap = add
    return center[0].buffer(center[1])



# create the ouput fc
incircles = arcpy.management.CreateFeatureclass("memory", "Incircles")
arcpy.management.AddField(incircles, "FID", "LONG")

# create the incircles
with arcpy.da.InsertCursor(incircles, ["SHAPE@", "FID"]) as i_cursor:
    with arcpy.da.SearchCursor("TestPolygons", ["SHAPE@", "OID@"]) as s_cursor:
        for shp, oid in s_cursor:
            ic = create_incircle(shp)
            i_cursor.insertRow([ic, oid])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1670429585805.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/57876i84F3A9CDF4735DA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1670429585805.png" alt="JohannesLindner_0-1670429585805.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is quite slow (1 - 2 seconds per feature), probably because the densification in line 5 adds lots of vertices. This can probably be optimized much, but it works as a quick-and-dirty approach. Sadly, it requires an Advanced license for the Thiessen polygons.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:18:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/circle-filling-a-polygon/m-p/1238776#M63115</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-12-07T16:18:08Z</dc:date>
    </item>
  </channel>
</rss>

