<?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: Detect and remove overlaps resulting from polygons with crossing edges in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1637426#M97655</link>
    <description>&lt;P&gt;I think you can identify those specific overlapping conditions using the &lt;A href="https://pro.arcgis.com/en/pro-app/3.3/arcpy/classes/polygon.htm" target="_blank" rel="noopener"&gt;Polygon&lt;/A&gt; geometry and arcpy.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import combinations

#define input polygon layer
poly_fc = r"input_polygon"

#initialize an empty overlap layer to insert into
arcpy.management.CreateFeatureclass(arcpy.env.workspace, 'overlap_polygon', "POLYGON")
arcpy.management.AddField('overlap_polygon', 'ID', 'DOUBLE')
counter = 1

# Get all geometries
geo_list = [row[0] for row in arcpy.da.SearchCursor(poly_fc,'SHAPE@')]

# pairwise compare all geometries
for poly, compare in combinations(geo_list, 2):
    # test for disjoint (if they don't touch at all, stop here)
    if not poly.disjoint(compare):
        # test for contain/within (if fully enclosed by another, stop here)
        if not (poly.contains(compare) or poly.within(compare)):
            # write the intersecting geometry to our overlap_polygon feature class.
            intersect_geo = poly.intersect(compare,4)
            # check for zero area
            if intersect_geo.getArea() &amp;gt; 0:
                # Need at least one non-shape field for Insert Cursor which is why we're using a dummy counter
                with arcpy.da.InsertCursor('overlap_polygon', ['ID', 'SHAPE@']) as cursor:
                    cursor.insertRow((counter,intersect_geo))
                    counter+=1&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="BrennanSmith1_0-1753817914892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137471iCE3652D3F15D7556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrennanSmith1_0-1753817914892.png" alt="BrennanSmith1_0-1753817914892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Actually, I think we can edit the geometries directly with this approach.&amp;nbsp; Code is sloppy but worked on my demo dataset.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import combinations

#define input polygon layer
poly_fc = r"input_polygon"

# make a copy because we're going to be editing it in place
arcpy.management.CopyFeatures(poly_fc, 'edited_polygon')

# Get a dictionary of OIDs and geometries
geo_dict = {row[0]:row[1] for row in arcpy.da.SearchCursor('edited_polygon',['OID@','SHAPE@'])}

# pairwise compare all OIDs
for oid1, oid2 in list(combinations(geo_dict, 2)):
    # get geometries for those IDs
    geo1 = geo_dict[oid1]
    geo2 = geo_dict[oid2]
    # test for disjoint (if they don't touch at all, stop here)
    if not geo1.disjoint(geo2):
        # test for contain/within (if fully enclosed by another, stop here)
        if not (geo1.contains(geo2) or geo1.within(geo2)):
            # check for intersecting geometry
            intersect_geo = geo1.intersect(geo2,4)
            if intersect_geo.getArea() &amp;gt; 0:
                # determine which geometry is larger
                if geo1.getArea() &amp;gt; geo2.getArea():
                    # and erase the overlap
                    with arcpy.da.UpdateCursor('edited_polygon', 'SHAPE@','OBJECTID = '+str(oid2)) as cursor:
                        for row in cursor:
                            row[0] = geo2.difference(geo1)
                            cursor.updateRow(row) 
                else:
                    with arcpy.da.UpdateCursor('edited_polygon', 'SHAPE@','OBJECTID = '+str(oid1)) as cursor:
                        for row in cursor:
                            row[0] = geo1.difference(geo2)
                            cursor.updateRow(row) &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="BrennanSmith1_1-1753819606454.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137473iE27068B449509AF6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrennanSmith1_1-1753819606454.png" alt="BrennanSmith1_1-1753819606454.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jul 2025 20:06:53 GMT</pubDate>
    <dc:creator>BrennanSmith1</dc:creator>
    <dc:date>2025-07-29T20:06:53Z</dc:date>
    <item>
      <title>Detect and remove overlaps resulting from polygons with crossing edges</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1636811#M97595</link>
      <description>&lt;P&gt;I have a polygon layer with overlapping polygons (drawn on top of each other not adjacent and only contiguous for two edges (polygon 1 and 4 on the outer rim)) that should not have any overlap that results from crossing polygon edges (the overlap between polygon 1 and 5 and the one between 2 and 3, see below, should be eliminated and being merged with the bigger of the involved overlapping polygon). Overlaps between polygons 1 and 2,&amp;nbsp; 1 and 3, 1 and 4, and 1 and 6 are to be kept as no edge crossing is taking place.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context: the polygons are meant to be in a print product where edges are set to overprint, so polygons overlapping are not spared out and edges crossing another feature will be visible.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_6-1753691667725.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137306iE8B6371CEBE6D66D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_6-1753691667725.png" alt="AlineWbg_6-1753691667725.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_7-1753691677208.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137307i674403512EE300C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_7-1753691677208.png" alt="AlineWbg_7-1753691677208.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/remove-overlap-multiple.htm" target="_self"&gt;Remove Overlap (multiple) (Analysis)&lt;/A&gt;&amp;nbsp;tool with the Thiessen method I end up with 2 valid features (below), while 4 have no geometry anymore, as overlaps combines features that are on top of each other. This tool only produces a target result for overlapping features with crossing edges that are not fully contained within another feature in the layer.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_10-1753692481342.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137310i9808488B8D99068A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_10-1753692481342.png" alt="AlineWbg_10-1753692481342.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When I create a topology where I don't allow overlaps I end up with the following polygon errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_11-1753692764110.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137311i6120DFD5F6CD8BE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_11-1753692764110.png" alt="AlineWbg_11-1753692764110.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But only the two highlighted in yellow are the ones I would be interested fixing.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_12-1753692797247.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137312i04999956DEBF2FDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_12-1753692797247.png" alt="AlineWbg_12-1753692797247.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Manually and with few polygons this is all doable, but I have layers with many polygons and would like to automatize that, without double-checking if the overlap is an overlap with crossing edges or just a polygon fully contained in another one.&lt;/P&gt;&lt;P&gt;The&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/analysis/intersect.htm" target="_self"&gt;Intersect (Analysis)&lt;/A&gt;&amp;nbsp;tool results in many duplicate geometries and removes the biggest polygon.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlineWbg_13-1753693489855.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137313i8FF4F494236FC09F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlineWbg_13-1753693489855.png" alt="AlineWbg_13-1753693489855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If there's only a handful of polygons some manual handling (to treat only the overlaps with crossing edges) with the help of topology is doable, but I'm looking at polygon layers with many polygons and I would like to automate this.&lt;/P&gt;&lt;P&gt;If there was a way to do the intersection that keeps all the polygons, then detect polygons that have &lt;STRONG&gt;vertices in another polygon&lt;/STRONG&gt; (so not a detached polygon) and if they do &lt;STRONG&gt;NOT all of them&lt;/STRONG&gt; (which would imply crossing edges) I could then use&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/eliminate.htm" target="_self"&gt;Eliminate (Data Management)&lt;/A&gt;&amp;nbsp;tool and merge all the selected polygons with the neighboring polygon with the largest area for instance.&lt;/P&gt;&lt;P&gt;I would be happy for an input in order to solve that specific problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jul 2025 09:29:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1636811#M97595</guid>
      <dc:creator>Aline-Wbg</dc:creator>
      <dc:date>2025-07-28T09:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Detect and remove overlaps resulting from polygons with crossing edges</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1637426#M97655</link>
      <description>&lt;P&gt;I think you can identify those specific overlapping conditions using the &lt;A href="https://pro.arcgis.com/en/pro-app/3.3/arcpy/classes/polygon.htm" target="_blank" rel="noopener"&gt;Polygon&lt;/A&gt; geometry and arcpy.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import combinations

#define input polygon layer
poly_fc = r"input_polygon"

#initialize an empty overlap layer to insert into
arcpy.management.CreateFeatureclass(arcpy.env.workspace, 'overlap_polygon', "POLYGON")
arcpy.management.AddField('overlap_polygon', 'ID', 'DOUBLE')
counter = 1

# Get all geometries
geo_list = [row[0] for row in arcpy.da.SearchCursor(poly_fc,'SHAPE@')]

# pairwise compare all geometries
for poly, compare in combinations(geo_list, 2):
    # test for disjoint (if they don't touch at all, stop here)
    if not poly.disjoint(compare):
        # test for contain/within (if fully enclosed by another, stop here)
        if not (poly.contains(compare) or poly.within(compare)):
            # write the intersecting geometry to our overlap_polygon feature class.
            intersect_geo = poly.intersect(compare,4)
            # check for zero area
            if intersect_geo.getArea() &amp;gt; 0:
                # Need at least one non-shape field for Insert Cursor which is why we're using a dummy counter
                with arcpy.da.InsertCursor('overlap_polygon', ['ID', 'SHAPE@']) as cursor:
                    cursor.insertRow((counter,intersect_geo))
                    counter+=1&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="BrennanSmith1_0-1753817914892.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137471iCE3652D3F15D7556/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrennanSmith1_0-1753817914892.png" alt="BrennanSmith1_0-1753817914892.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Actually, I think we can edit the geometries directly with this approach.&amp;nbsp; Code is sloppy but worked on my demo dataset.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import combinations

#define input polygon layer
poly_fc = r"input_polygon"

# make a copy because we're going to be editing it in place
arcpy.management.CopyFeatures(poly_fc, 'edited_polygon')

# Get a dictionary of OIDs and geometries
geo_dict = {row[0]:row[1] for row in arcpy.da.SearchCursor('edited_polygon',['OID@','SHAPE@'])}

# pairwise compare all OIDs
for oid1, oid2 in list(combinations(geo_dict, 2)):
    # get geometries for those IDs
    geo1 = geo_dict[oid1]
    geo2 = geo_dict[oid2]
    # test for disjoint (if they don't touch at all, stop here)
    if not geo1.disjoint(geo2):
        # test for contain/within (if fully enclosed by another, stop here)
        if not (geo1.contains(geo2) or geo1.within(geo2)):
            # check for intersecting geometry
            intersect_geo = geo1.intersect(geo2,4)
            if intersect_geo.getArea() &amp;gt; 0:
                # determine which geometry is larger
                if geo1.getArea() &amp;gt; geo2.getArea():
                    # and erase the overlap
                    with arcpy.da.UpdateCursor('edited_polygon', 'SHAPE@','OBJECTID = '+str(oid2)) as cursor:
                        for row in cursor:
                            row[0] = geo2.difference(geo1)
                            cursor.updateRow(row) 
                else:
                    with arcpy.da.UpdateCursor('edited_polygon', 'SHAPE@','OBJECTID = '+str(oid1)) as cursor:
                        for row in cursor:
                            row[0] = geo1.difference(geo2)
                            cursor.updateRow(row) &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="BrennanSmith1_1-1753819606454.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/137473iE27068B449509AF6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="BrennanSmith1_1-1753819606454.png" alt="BrennanSmith1_1-1753819606454.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jul 2025 20:06:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1637426#M97655</guid>
      <dc:creator>BrennanSmith1</dc:creator>
      <dc:date>2025-07-29T20:06:53Z</dc:date>
    </item>
    <item>
      <title>Re: Detect and remove overlaps resulting from polygons with crossing edges</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1645703#M98550</link>
      <description>&lt;P&gt;Dear Brennan thank you so much for your help and putting in your time! Your updated script works perfectly!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Aug 2025 16:38:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/detect-and-remove-overlaps-resulting-from-polygons/m-p/1645703#M98550</guid>
      <dc:creator>Aline-Wbg</dc:creator>
      <dc:date>2025-08-26T16:38:11Z</dc:date>
    </item>
  </channel>
</rss>

