ArcGIS消除图斑重叠错误

在生产中,经常会遇见有图斑重叠这种拓扑错误的矢量,大部分情况下,需要人工比对影像处理。但是如果只需要用到这些矢量的形状、面积,可以在ArcMap中用以下方法,快速消除图斑重叠错误,不必手工处理。

如下图所示,两个图斑存在重叠部分。

首先,使用 Intersect 工具,得到矢量所有相交部分,这时,相交结果矢量里,每一个图斑都有一个或以上形状完全相同的图斑存在。然后,使用 Delete Identical 工具,删除形状相同的其他图斑,删除结果就是矢量里所有相交的部分。

最后,使用 Update 工具,将删除结果更新到源矢量里,这样就将所有重叠部分独立出来,成为单独的图斑。

把这些步骤,写入脚本保存。

# coding:utf-8
import os
import arcpy


def GetNewFileName(dir, baseName):
    for i in range(1, 100):
        if not os.path.exists(os.path.join(dir, baseName + str(i))):
            return os.path.join(dir, baseName + str(i))
    return os.path.join(dir, baseName)


overlapedShp = arcpy.GetParameterAsText(0)
resultShp = arcpy.GetParameterAsText(1)

resultDir = os.path.split(resultShp)[0]
intersectedShp = GetNewFileName(resultDir, 'temp') + '.shp'

arcpy.Intersect_analysis([overlapedShp], intersectedShp)
arcpy.DeleteIdentical_management(intersectedShp, ['shape'])
arcpy.Update_analysis(overlapedShp, intersectedShp, resultShp)
arcpy.Delete_management(intersectedShp)

原文地址:https://www.cnblogs.com/sunnyeveryday/p/9095704.html