arcgis.geoprocessing module

Users can create and share geoprocessing tools in the GIS. The arcgis.geoprocessing module lets you import geoprocessing toolboxes as native Python modules. You can call the functions available in the imported module to invoke these tools. The module also provides simple types that can be used as parameters for these tools along with native Python types.

import_toolbox

arcgis.geoprocessing.import_toolbox(url_or_item, gis=None, verbose=False)

Imports geoprocessing toolboxes as native Python modules. You can call the functions available in the imported module to invoke these tools.

Argument

Description

url_or_item

location of toolbox, can be a geoprocessing server url or Item of type: Geoprocessing Service

gis

optional GIS, the GIS used for running the tool. arcgis.env.active_gis is used if not specified

verbose

optional bool, set to True to print the generated module

Returns module with functions for the various tools in the toolbox

DataFile

class arcgis.geoprocessing.DataFile(url=None, item_id=None, portal_item=None)

A data object containing a data source, used as input/output by some Geoprocessing tools

Argument

Description

url

optional string, URL to the location of the data file.

item_id

optional string, The id of the uploaded file returned as a result of the upload operation.

portal_item

optional Item. A data type item used for GP tool.

download(save_path=None)

Downloads the data to the specified folder or a temporary folder if a folder isn’t provided

classmethod from_dict(datadict)

Creates an instance of this class from its dict representation.

classmethod from_str(url)

Creates a data file from a url.

to_dict()

Converts an instance of this class to its dict representation.

LinearUnit

class arcgis.geoprocessing.LinearUnit(distance, units)

A data object containing a linear distance, used as input to some Geoprocessing tools

Argument

Description

distance

required number, the value of the linear distance.

units

required string, unit type of the linear distance, such as “Meters”, “Miles”, “Kilometers”, “Inches”, “Points”, “Feet”, “Yards”, “NauticalMiles”, “Millimeters”, “Centimeters”, “DecimalDegrees”, “Decimeters”

classmethod from_dict(datadict)

Creates an instance of this class from its dict representation.

classmethod from_str(how_far)

Creates a linear unit from a string like ‘5 miles’.

to_dict()

Converts an instance of this class to its dict representation.

RasterData

class arcgis.geoprocessing.RasterData(url=None, format=None, item_id=None)

A data object containing a raster data source, used as input/output by some Geoprocessing tools

Argument

Description

url

optional string, URL to the location of the raster data file.

item_id

optional string, The id of the uploaded file returned as a result of the upload operation.

format

optional string, Specifies the format of the raster data, such as “jpg”, “tif”, etc.

classmethod from_dict(datadict)

Creates an instance of this class from its dict representation.

to_dict()

Converts an instance of this class to its dict representation.

GPService

class arcgis.geoprocessing.GPService(url: str, gis: arcgis.gis.GIS = None)

A geoprocessing service can contain one or more tools that use input data from a client application, process it, and return output in the form of features, maps, reports, files, or services. These tools are first authored and run in ArcGIS Pro or ArcGIS Desktop, typically as a custom model or script tools, before being shared to an ArcGIS Server.

property info
property properties

Returns the Service’s Properties

Returns

dict

refresh()

Reloads the Service Information

property tasks

returns the GP Tasks

GPTask

class arcgis.geoprocessing.GPTask(url: str, parent: arcgis.geoprocessing._service.GPService, gis: arcgis.gis.GIS = None)

The GP Task resource represents a single task in a geoprocessing service published using ArcGIS Server. It provides basic information about the task including its name and display name. It also provides detailed information about the various input and output parameters exposed by the task.

property choice_list

Returns a Map of Parameters with Choice Lists.

Returns

dict

default_value(name: str) → object

Gets a parameter’s default value.

Returns

object

property help_url

Returns the URL to the documentation for the GP Task.

Returns

str

property name

Name of the geoprocessing tasks

Returns

str

property properties

Returns the Service’s Properties

Returns

dict

GPInfo

GPJob

class arcgis.geoprocessing.GPJob(future, gptool, jobid, task_url, gis, notify=False)

Represents a Single Geoprocessing Job. The GPJob class allows for the asynchronous operation of any geoprocessing task. To request a GPJob task, the code must be called with future=True or else the operation will occur synchronously. This class is not intended for users to call directly.

Argument

Description

future

Required ccurrent.futures.Future. The async object created by the geoprocessing (GP) task.

gptool

Required Layer. The Geoprocessing Service

jobid

Required String. The unique ID of the GP Job.

task_url

Required String. The URL to the GP Task.

gis

Required GIS. The GIS connection object

notify

Optional Boolean. When set to True, a message will inform the user that the geoprocessing task has completed. The default is False.

cancel()

Attempt to cancel the call. If the call is currently being executed or finished running and cannot be cancelled then the method will return False, otherwise the call will be cancelled and the method will return True.

Returns

boolean

cancelled()

Return True if the call was successfully cancelled.

Returns

boolean

done()

Return True if the call was successfully cancelled or finished running.

Returns

boolean

property ellapse_time

Get the Ellapse Time for the Job

property messages

Get the service’s messages

Returns

List

result()

Return the value returned by the call. If the call hasn’t yet completed then this method will wait.

Returns

object

running()

Return True if the call is currently being executed and cannot be cancelled.

Returns

boolean

property status

Get the GP status

Returns

String

property task

Get the task name. :return: string

Toolbox

class arcgis.geoprocessing._tool.Toolbox(url, gis=None)

A collection of geoprocessing tools.

property tools

List of tools in this toolbox