Using geoprocessing tasks in Python scripts

ArcGIS Server geoprocessing tasks can be used in scripts. The basic steps are

Example script:

import arcpy, time

# Add a geoprocessing service as a toolbox
# Syntax: ArcGIS Server link;ToolBoxName with the Tool name is the next attribute

# 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

# 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:

# 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)"C:/mydata/gpResults.gbd/output1")

Additional topics:



Adding and removing toolboxes

Details on how to add toolboxes and geoprocessing services within a script

FeatureSets and RecordSets

Details about creating, loading, and saving feature set and record set data

Getting results from a geoprocessing tool

Details about querying the result of a tool or task


Details of result class properties and methods

Using geoprocessing tasks in scripts

Related Topics