Arcgis中消除子流域划分时出现的零碎图斑或狭长面(Eliminate)

在ArcGIS中,由于叠加操作可能会产生碎图斑和狭长面,影响后续分析。可以通过数据管理工具的"消除"功能或者Python脚本来解决这一问题。本文介绍了使用ArcGIS内置消除工具以及自定义Python脚本实现图斑融合的方法。
部署运行你感兴趣的模型镜像

 在ArcGIS中叠加操作会带来碎图斑或狭长面,而这些碎图斑或狭长面又会影响后续的判断。所以就需要消除。

     例如:

具体操作有以下方式:

1、最简单的的方法就是使用ArcGIS提供的“消除工具”。在"数据管理工具"——“制图综合”——“消除”。

2、使用Python脚本

# -*-coding:gbk-*-

 

import arcpy

from arcpy import env

import time

 

# 融合指定条件的图斑

 

try:

    source_gdb_path = "F:/gisData/"  # 原始图层工作空间

    in_features = "subbasin.shp"   # 输入图层

    expression = "SHAPE_AREA <50 or SHAPE_Area/ SHAPE_Length<0.2"  # 融合限制条件

 

    env.workspace = source_gdb_path

    time_begin = time.time()

    print "消除指定条件下的要素{0}".format(expression)

 

    tempLayer = "block_layer"

    # SearchCursor

    fcount = len([feature[0] for feature in arcpy.da.SearchCursor(in_features, "SHAPE_AREA", expression)])

    while (fcount > 0):

        print('fcount:{0}  Time : {1} s'.format(fcount, time.time() - time_begin))

 

        tempLayer = "{0}_b".format(tempLayer)

        # MakeFeatureLayer

        arcpy.MakeFeatureLayer_management(in_features, tempLayer)

 

        in_features = "{0}_E".format(in_features)

        if arcpy.Exists(in_features):

            arcpy.Delete_management(in_features)

        # SelectLayerByAttribute to define feature to be eliminated

        arcpy.SelectLayerByAttribute_management(tempLayer, "NEW_SELECTION", expression)

 

        # Eliminate

        arcpy.Eliminate_management(tempLayer, in_features, "AREA")

        fcount2 = len([feature[0] for feature in arcpy.da.SearchCursor(in_features, "SHAPE_AREA", expression)])

        if fcount2 == fcount:

            break

        else:

            fcount = fcount2

 

    print "Total Time {0}".format(time.time() - time_begin)

except Exception, e:

    print e.message.decode("utf_8")
 

 

 

 

 

 

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值