Exists

サマリ

指定したデータ オブジェクトが存在するかどうかを判別します。フィーチャクラス、テーブル、データセット、シェープファイル、ワークスペース、レイヤ、およびファイルが、現在のワークスペースに存在するかどうかを確認します。この関数は、その要素が存在するかどうかを示すブール値を返します。

構文

Exists (dataset)
パラメータ説明データ タイプ
dataset

The name, path, or both of a feature class, table, dataset, layer, shapefile, workspace, or file to be checked for existence.

String
リターン
データ タイプ説明
Boolean

指定した要素が存在する場合は、ブール値 True が返されます。

コードのサンプル

Exists の例

指定したデータ オブジェクトが存在するかどうかを確認します。

import arcpy
from arcpy import env

# Set the current workspace
# 
env.workspace = "C:/Data/MyData.gdb"

# Check for existance of the output data before running the Buffer tool.
# 
if arcpy.Exists("RoadsBuff"):
    arcpy.Delete_management("RoadsBuff")

try:
    arcpy.Buffer_analysis("Roads", "RoadsBuff", "100 meters")
    arcpy.AddMessage("Buffer complete")
except:
    arcpy.AddError(arcpy.GetMessages(2))

関連項目


7/10/2012