操作方法
在 ArcGIS Pro 中,字段工具集包含用于创建和修改任何地理数据库表或要素类的字段的工具。 可以通过在 ArcGIS Pro 中运行 Python 脚本来进行这些修改,本文提供了工作流。
下图显示了 Schools_all 属性表,其中字段别名包含下划线和小写字母。
import arcgis import os
arcpy.env.overwriteOutput = True
<variableName> = arcpy.ListFields('<layerName>')
print("Changing the field alias to field name by Capitalizing the initial letter") for field in <variableName>: if not field.required: arcpy.management.AlterField('<layerName>', field.name, field.name, field.name.rstrip(field.name[-2:])) arcpy.management.AlterField('<layerName>', field.name, field.name, field.name.replace("_"," ").title()) print("Completed")
以下代码块演示了完整的工作脚本。
import arcpy import os arcpy.env.overwriteOutput=True infeature=arcpy.GetParameterAsText(0) fields=arcpy.ListFields('Schools_all') print("Changing the field alias to field name by Capitalizing the initial letter") for field in fields: if not field.required: arcpy.management.AlterField('Schools_all', field.name, field.name,field.name.rstrip(field.name[-2:])) arcpy.management.AlterField('Schools_all', field.name, field.name, field.name.replace("_"," ").title()) print("Completed")
下图显示了在 ArcGIS Pro 中使用 Python 更新的字段别名。
文章 ID: 000029252
获取来自 ArcGIS 专家的帮助
下载 Esri 支持应用程序