Verwenden von Geoverarbeitungs-Tasks in Python-Skripten
ArcGIS Server-Geoverarbeitungs-Tasks können in Skripten verwendet werden. Die grundlegenden Schritte lauten wie folgt:
- Fügen Sie den Service als Toolbox hinzu.
- Da für viele Tasks Feature-Sets und Recordsets verwendet werden, fragen Sie den Task ab, um das Feature-Set- oder Recordset-Schema abzurufen.
- Laden Sie Features oder Datensätze.
- Starten Sie die Ausführung des Werkzeugs.
- Fragen Sie das Ergebnis des Werkzeugs ab, und warten Sie auf den Abschluss der Ausführung.
- Fragen Sie das Ergebnis ab, um Ausgaben abzurufen.
Beispielskript:
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")
Weitere Themen:
|
Thema |
Beschreibung |
|---|---|
|
Informationen zum Hinzufügen von Toolboxes und Geoverarbeitungs-Services in einem Skript |
|
|
Informationen zum Erstellen, Laden und Speichern von Feature-Set- und Recordset-Daten |
|
|
Informationen zum Abfragen des Ergebnisses eines Werkzeugs oder eines Tasks |
|
|
Informationen zu Eigenschaften und Methoden von Ergebnisklassen |
Verwandte Themen
3/6/2012