• 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)
    
    
  • 相关阅读:
    POJ 1936 All in All
    Blue Jeans POJ 3080 寻找多个串的最长相同子串
    Spell checker POJ 1035 字符串
    密码锁
    luogu P1083 借教室
    BZOJ 1588: [HNOI2002]营业额统计
    BZOJ 1433: [ZJOI2009]假期的宿舍
    luogu P1231 教辅的组成
    luogu P2756 飞行员配对方案问题
    luogu P3386 【模板】二分图匹配
  • 原文地址:https://www.cnblogs.com/sunnyeveryday/p/9095704.html
Copyright © 2020-2023  润新知