方法
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 エキスパートのサポートを受ける
今すぐチャットを開始