arcgis更改图层字段名脚本

话不多说,上脚本源码,复制黏贴即可

python 复制代码
#-*- coding:utf-8 -*-
__author__ = 'lumen'
import arcpy 
#输入图层
InputFeature = arcpy.GetParameterAsText(0)
#原始字段
oldField = arcpy.GetParameterAsText(1)
# 获取原始字段类型
oldFieldType = ''
desc = arcpy.Describe(InputFeature)
# 获取字段列表
fields = desc.fields
# 遍历字段列表并打印字段名和字段类型
arcpy.AddMessage(fields)
for field in fields:
    if field.name==oldField:
        oldFieldType = field.type
arcpy.AddMessage(oldFieldType)
#这是xin字段
newField = arcpy.GetParameterAsText(2)
arcpy.AddMessage('fields has been registered')
#为新字段添加唯一指定字段
arcpy.AddField_management(InputFeature, newField, oldFieldType)
#获取数据游标
cursor = arcpy.UpdateCursor(InputFeature)

#遍历数据
for row in cursor:
    newValue = row.getValue(oldField)
    row.setValue(newField,newValue) 
    cursor.updateRow(row)
# 使用 DeleteField 工具删除字段
arcpy.DeleteField_management(InputFeature, oldField)
#完活儿
arcpy.AddMessage('project succeed,best wishes for you')
# 删除游标对象
del cursor, row

安装后界面这样

相关推荐
weixin199701080167 分钟前
《1688物流API接口边界:logistics.trace.get 与 freight.template.list 的隐藏约束》(附Python源码)
windows·python·list
mhmh1231 小时前
Python 对象模型与数据模型:魔术方法、描述符与元类深度解析
开发语言·python
估值探索者1 小时前
【Python量化策略实战 #02】多因子合成mom和vol两因子打分合成
开发语言·c++·python·数据挖掘·c#
FYKJ_20102 小时前
SSM校园失物招领系统41452-计算机课程设计、毕业设计
java·vue.js·spring boot·python·mysql·typescript·spark
头发够用的程序员2 小时前
TensorRT 自定义算子插件实战(一):从零手写 customScaledTanh
c++·人工智能·pytorch·python·深度学习·边缘计算·jetson
xiaoqi01953 小时前
期货量化软件回测方式深度横评:期魔方、文华财经、无限易、TB开拓者、金字塔全面对比
python·机器学习
别动我齐刘海3 小时前
简历技术栈全面复习——UDP / TCP / CAN / ZMQ / Protobuf 通信工程
网络·c++·python·tcp/ip·机器学习·udp·github
天赐范式3 小时前
天赐范式第181天:让耦合开始失稳——竞争耦合与线性失稳边界
python·数字生命·天赐范式·lyapunov指数·动态运行时·耦合失稳·laplacian矩阵
happylifetree3 小时前
Python15:核心语法-数据存储与运算-字符串拼接
python
huisheng_qaq4 小时前
【Python基础篇-09】深入理解python的闭包与装饰器
python·闭包