arcpy.management.Copy(in_data, out_data, {data_type}, {associated_data})
|
名前
|
説明
|
データ タイプ
|
|
in_data
|
コピーされるデータ。
|
Data Element
|
|
out_data
|
出力データの場所および名前。 出力データのファイル名の拡張子は、入力データの拡張子と一致する必要があります。 たとえば、ファイル ジオデータベースをコピーしている場合、出力データ エレメントの拡張子は .gdb である必要があります。
|
Data Element
|
|
data_type
(オプション)
|
コピーされるディスク上のデータのタイプ。
このパラメーターは、2 つの異なるデータ タイプ間で名前が競合する場合にのみ指定する必要があります。 たとえば、フィーチャクラスと同じ名前を持つリレーションシップ クラスがジオデータベースに含まれていることがあります。 そのような場合には、関連するキーワードを指定します。
|
String
|
|
associated_data
[[from_name, data_type, to_name, config_keyword],...]
(オプション)
|
入力に関連データがあるとき、このパラメーターを使用して、関連する出力データの名前とコンフィグレーション キーワードを制御できます。
from_name と to_name の列名は、to_name の値が out_data パラメーター値で使用されていない場合は同じになります。 out_data の値に名前が存在する場合、from_name の値にアンダースコアと数字を追加した一意の to_name の値 (たとえば、rivers_1) が作成されます。
値テーブル列:
From Name—The data associated with the input data, which will also be copied.
Data Type—The type of the data on disk that will be copied. The only time you need to provide a value is when a geodatabase contains a feature dataset and a feature class with the same name. In this case, use the correct data type, FeatureDataset or FeatureClass, of the item you want to copy.
To Name—The name of the copied data in the output.
Config Keyword—The geodatabase storage parameters (configuration).
|
Value Table
|
コードのサンプル
次の Python ウィンドウ スクリプトは、イミディエイト モードで Copy 関数を使用する方法を示しています。
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.management.Copy("majorrds.shp", "C:/output/majorrdsCopy.shp")
Copy の例 2 (スタンドアロン スクリプト)
次の Python スクリプトは、スタンドアロン スクリプトで Copy 関数を使用する方法を示しています。
# Name: Copy_Example2.py
# Description: Copy major roads dataset to preserve the original data
# Import system modules
import arcpy
# Set workspace
arcpy.env.workspace = "C:/data"
# Set local variables
in_data = "majorrds.shp"
out_data = "C:/output/majorrdsCopy.shp"
# Run Copy
arcpy.management.Copy(in_data, out_data)
Copy の例 3 (スタンドアロン スクリプト)
次の Python スクリプトは、Copy 関数で associated_data パラメーターを使用する方法を示しています。
# Name: Copy_Example3.py
# Description: Copy a feature dataset and specify associated_data
# Import system modules
import arcpy
# The input is a feature dataset containing 3 feature classes: lakes, cities, rivers
in_data = "C:/data/proj.gdb/mexico"
out_data = "C:/data/proj.sde/mexico"
associated_data = ";".join(["lakes FeatureClass mexico_lakes #",
"cities FeatureClass mexico_cities #",
"rivers FeatureClass mexico_rivers #"])
# Rename each feature class during the copy operation using the associated_data parameter
arcpy.management.Copy(in_data, out_data, associated_data=associated_data)
次の Python ウィンドウ スクリプトは、フィーチャ データセットを使用して Copy 関数を使用する方法およびエンタープライズ ジオデータベース環境内で associated_data パラメーターを指定する方法を示しています。
import arcpy
arcpy.management.Copy(
in_data=r"C:\Users\GIS\SQLServerDatabase.sde\DBO.Mexico",
out_data=r"C:\Users\GIS\SQLServerDatabase.sde\DBO.PyCmd_Mexico",
data_type="FeatureDataset",
associated_data="DBO.Rivers FeatureClass DBO.PyCmd_Rivers #;DBO.Lakes FeatureClass DBO.PyCmd_Lakes #;DBO.Cities FeatureClass DBO.PyCmd_Cities #"
)
Copy の例 5 (スタンドアロン スクリプト)
次の Python スクリプトは、フィーチャ データセットを使用して Copy 関数を使用する方法およびエンタープライズ ジオデータベース環境内で associated_data パラメーターを指定する方法を示しています。
# Description: Copy a feature dataset and specify associated_data within an
# Enterprise geodatabase environment
# Import system modules
import arcpy
# The input is a feature dataset containing 3 feature classes: lakes, cities,
# rivers.
in_data = r"C:\Users\GIS\SQLServerDatabase.sde\DBO.Mexico"
# The output is a new feature dataset that the feature classes from in_data will
# be copied to
out_data = r"C:\Users\GIS\SQLServerDatabase.sde\DBO.Py_Mexico"
# Define schema of the from_name and to_name values when preparing data to be
# created in an enterprise geodatabase
associated_data = ";".join(["DBO.Lakes FeatureClass DBO.Py_Lakes #",
"DBO.Cities FeatureClass DBO.Py_Cities #",
"DBO.Rivers FeatureClass DBO.Py_Rivers #"])
# Rename each feature class during the copy operation using the associated_data
# parameter
arcpy.management.Copy(in_data, out_data, associated_data=associated_data)