操作方法
在 ArcGIS Pro 中,常规工具集包含用于对地理数据库表或要素类执行常规数据管理操作的工具。 可以通过在 ArcGIS Pro 中运行 Python 脚本来进行这些修改。 本文提供了使用 ArcGIS API for Python 重命名多个要素类(如下面的目录窗格中所示)的工作流。


import arcpy
arcpy.env.workspace = r"<gdbFolderPath>"
for fc in arcpy.ListFeatureClasses() + arcpy.ListTables():
name = fc.split("<separator>")[<maxSplit>]
new_name = "<addToFeatureClassName>" + name
try:
arcpy.management.Rename(fc, new_name)
except Exception as e:
print(f"Could not rename {fc} to {new_name}: {e}")
以下代码块演示了完整工作脚本。
import arcpy
arcpy.env.workspace = r"C:\Users\ISC-DT27\Documents\Article work\29660\LabelMapFeatures\Portland Labels.gdb"
for fc in arcpy.ListFeatureClasses() + arcpy.ListTables():
name = fc.split(" ")[-1]
new_name = "Test_" + name
try:
arcpy.management.Rename(fc, new_name)
except Exception as e:
print(f"Could not rename {fc} to {new_name}: {e}")
下图显示了在 ArcGIS Pro 中使用 Python 更新的要素类名称。

文章 ID: 000029660
获取来自 ArcGIS 专家的帮助
立即开始聊天