本文主要是介绍Arcgis分割图斑编码工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、分割图斑编码:分割图斑在原图斑编码的基础上_1、_2…的续编。
二、代码:
# coding: utf-8
import arcpy
from collections import Counterdef get_repeat_values(in_table, field):fields_values = []with arcpy.da.SearchCursor(in_table, field) as rows:for row in rows:code = str(row[0])if code != "" or code != " ":fields_values.append(code)field_dict = dict(Counter(fields_values))result = [key for key, value in field_dict.items() if value > 1]return resultdef coding(table, field, repeat_values):for value in repeat_values:where_cause = "{0}='{1}'".format(field, value)count = 1;with arcpy.da.UpdateCursor(table, field, where_cause) as cursor:for row in cursor:row[0] = "{0}_{1}".format(str(row[0]), str(count).rjust(1, "0"))cursor.updateRow(row)count = count + 1
fcs = arcpy.GetParameterAsText(0)
field = arcpy.GetParameterAsText(1)
repeat_values = get_repeat_values(fcs, field)
coding(fcs, field, repeat_values)
三、工具箱:
四、下载:
https://www.xsoftnet.com/share/a0000Pg39FnxD.html
这篇关于Arcgis分割图斑编码工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!