Python スクリプトでのジオプロセシング タスクの使用
ArcGIS Server ジオプロセシング タスクはスクリプト内で使用できます。基本的な手順は次のとおりです。
- サービスをツールボックスとして追加します。
- 多くのタスクがフィーチャ セットとレコード セットを使用するため、フィーチャまたはレコード セット スキーマを取得するためのタスクを検索します。
- フィーチャまたはレコードを読み込みます。
- ツールの実行を開始します。
- ツールの結果を検索して、実行が完了するのを待ちます。
- 結果を検索して出力を取得します。
スクリプト例:
import arcpy, time
# Add a geoprocessing service as a toolbox
# Syntax: ArcGIS Server link;ToolBoxName with the Tool name is the next attribute
#
arcpy.ImportToolbox("http://degrassi/arcgis/services;BufferToolBox","Buffer")
# One of the tasks is BufferPoints and its first parameter is a feature
# set. Get the feature set from the task.
#
inFeatSet = arcpy.GetParameterValue("Buffer", 0)
# Load an existing feature class into the feature set
#
inFeatSet.load("C:/datasets/aoi/observations.shp")
# Start execution of the task
# Service is executed by the toolName_aliasName
#
result = arcpy.Buffer_Buffer(inFeatSet, "500 feet")
# Query the result object to detect when the service has finished execution
#
while result.status < 4:
time.sleep(0.2)
# The output of this task is a feature set of the buffered points. Get the output
# by index and save to a geodatabase feature class.
#
outFeatSet = result.getOutput(0)
outFeatSet.save("C:/mydata/gpResults.gbd/output1")
追加のトピック:
|
トピック |
説明 |
|---|---|
|
スクリプト内にツールボックスおよびジオプロセシング サービスを追加する方法の詳細 |
|
|
フィーチャ セット データとレコード セット データの作成、読み込み、保存に関する詳細 |
|
|
ツールまたはタスクの結果の検索に関する詳細 |
|
|
結果クラスのプロパティとメソッドに関する詳細 |
関連項目
7/10/2012