ArcGIS消除圖斑重疊錯誤

在生產中,常常會碰見有圖斑重疊這種拓撲錯誤的矢量,大部分狀況下,須要人工比對影像處理。可是若是隻須要用到這些矢量的形狀、面積,能夠在ArcMap中用如下方法,快速消除圖斑重疊錯誤,沒必要手工處理。python

以下圖所示,兩個圖斑存在重疊部分。

工具

首先,使用 Intersect 工具,獲得矢量全部相交部分,這時,相交結果矢量裏,每個圖斑都有一個或以上形狀徹底相同的圖斑存在。而後,使用 Delete Identical 工具,刪除形狀相同的其餘圖斑,刪除結果就是矢量裏全部相交的部分。
code

最後,使用 Update 工具,將刪除結果更新到源矢量裏,這樣就將全部重疊部分獨立出來,成爲單獨的圖斑。
blog

把這些步驟,寫入腳本保存。utf-8

# 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)
相關文章
相關標籤/搜索