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

安装后界面这样

相关推荐
LoserChaser19 小时前
Flask 文件上传服务器 - 知识点总结
服务器·python·flask
cd9888019 小时前
2026年,哪家电销机器人定制更灵活?
python
二十七剑19 小时前
LangGraph 源码深度解析:_branch.py 条件分支底层实现原理
python
星座52819 小时前
破解水环境空间分析难题,迈向智慧水环境管理:ArcGIS水质评价、污染预测与洪水监测核心技术揭秘
arcgis·水环境·水文
KaMeidebaby19 小时前
卡梅德生物技术快报|噬菌体展示文库构建全流程解析 | 大豆球蛋白纳米抗体筛选实践
人工智能·python·tcp/ip·算法·机器学习
傻啦嘿哟19 小时前
为什么Python没有块级作用域?
开发语言·python
CC数学建模19 小时前
2026年第十六届APMCM 亚太地区大学生数学建模竞赛(中文赛项)赛题B题:高性能芯片热管理系统的优化问题完整思路、代码、模型、文章,全网首发高质量分享!
python·算法·数学建模
Maydaycxc19 小时前
Python 实现 RPA + AI 自动化:大模型 OCR + 网页操作完整源码实战
人工智能·python·opencv·selenium·自动化·ocr·rpa
stephon_10019 小时前
从零设计 Agent 上下文压缩:三级流水线与动态阈值,治好 context too long(附开源实现)
人工智能·python
love530love19 小时前
Anaconda Navigator 升级后图形界面启动失败故障修复实录
人工智能·windows·python·anaconda·navigator