TransWikia.com

Finding and deleting overlapping polygons using ArcMap

Geographic Information Systems Asked by MonkeyCousin on March 10, 2021

I have generated these (green) polygons in ArcMap 10.5.1 by: import XY data > buffer 5 m > minimum bounding geometry (plus a couple of other steps).

image.png
self-intersect of polygons

The screenshot is a self-intersect of the polygon layer. I need to achieve zero overlaps between polygons, by deleting the minimum number of them. I have tens of thousands of polygons.

Can someone suggest a way around this?

I have tried to select the points on the basis of their proximity to each other before buffering – any that are >= 10 m apart would survive the cull.
But my test of ArcGIS nearest neighbour analyses is not promising:

  • Average Nearest Neighbor (Spatial Statistics) gives only what the name says – not a feature class with attributes that can be queried / selected
  • Calculate Distance Band from Neighbor Count (Spatial Statistics) – likewise

One Answer

Script below fiinds connected elements and delete node with maximum number of neighbors in each group. It stops when no neighbors found. I use it to weed out intersecting sections but it works with polygons, see picture.

import arcpy
import pandas as pd
sections = arcpy.GetParameterAsText(0)
import networkx as nx

mxd = arcpy.mapping.MapDocument("CURRENT")
sections=arcpy.mapping.ListLayers(mxd,sections)[0]

table = 'in_memory/tbl'
caseField="IN_FID"
nearField = "NEAR_FID"

while True:
    arcpy.analysis.GenerateNearTable(sections, sections, table, 0, "NO_LOCATION", "NO_ANGLE", "ALL", "0", "PLANAR")
    tbl=arcpy.da.TableToNumPyArray(table,(caseField,nearField))
    n = len(tbl)
    if n == 0:break
    df=pd.DataFrame(tbl)
    df["Frequency"]=1
    fList=["Frequency"]
    sums=df.groupby([caseField])[fList].sum()
    aDict ={}
    for i,fr in sums.itertuples():
        aDict[i]=fr
    G = nx.Graph()
    for f,t in tbl:
        G.add_edge(f,t)
        G.add_node(f, nto = aDict[f])
    del tbl

    d = []
    for item in  nx.connected_components(G):
        lMax = -1
        for node in item:
            lCur = aDict[node]
            if lCur<lMax:continue
            lMax = lCur
            theNode = node
        d.append (theNode) 
    arcpy.AddMessage("%i groups found" %len(d))
    sections.setSelectionSet ("NEW",d)
    arcpy.DeleteFeatures_management(sections)    

enter image description here You'll need networkx module installed. If time is an issue use Copyfeature to in_memorysomething. It modifies original, so work on copy. In ArcMap options tick "overwrite output of geoprocessing operations".

Answered by FelixIP on March 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP