1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Arcgis中消除子流域划分时出现的零碎图斑或狭长面(Eliminate)

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

时间:2019-04-30 22:38:19

相关推荐

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

在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")

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。