1

I have a set of very large shapefiles and would like to merge polygons within these that share one vertex.

Currently they are all separate like so:

enter image description here

What tool can I use to merge all the polygons that share one vertex so in the above example the selected polygon would be part of the one to the left like so:

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
tom91
  • 115
  • 4

2 Answers2

4

Suggestion in my comments "Convert back to integer raster, region group, to polygons, dissolve to multipart" will work for polygons derived from rasters.

However in general it's better to start with suggestion by @Polygeo . You'll need to use script though:

import arcpy
import networkx as nx
##  replace 2 lines below to point to polygons and neighbours table
Nodes=r'C:\SCRATCH\SCRATCH.gdb\R2P'
Links=r'C:\SCRATCH\SCRATCH.gdb\NBRS'
fldFROM,fldTO="src_OBJECTID","nbr_OBJECTID"
G=nx.Graph()
with arcpy.da.SearchCursor(Links, (fldFROM,fldTO)) as cursor:
    for f,t in cursor:
        G.add_edge(int(f),int(t))
d,N=dict(),1
for group in nx.connected_components(G):
    for n in group:d[n]=N
    N+=1
with arcpy.da.UpdateCursor(Nodes, ("OBJECTID","GRP")) as cursor:
    for k, v in cursor:
        if k in d:v=d[k]
        else: N+=1;v=N
        cursor.updateRow((k,v))

Script assumes that your neighborhood table called NBRS, your polygons stored in file GDB and there is a field called "GRP" to store group numbers.

enter image description here

FelixIP
  • 22,922
  • 3
  • 29
  • 61
0

If the polygons are really connected to each other, a Union will merge the neighbors.

bugmenot123
  • 11,011
  • 3
  • 34
  • 69
  • 1
    Unfortunately, I've tried Union, including with an xy tolerance but it still produces a shape file where polygons sharing a vertex are separate. They definitely share a vertex because the shape files were made via converting a raster. Is there something else I can try? – tom91 May 09 '19 at 08:52