An overview of ArcPy functions

ArcPy provides a number of functions to better support workflows using Python.

In addition to the functions listed in this topic, all geoprocessing tools can be accessed as ArcPy functions; see Using tools in Python for more information. Additional functions can be found in other ArcPy modules, including the following:

Learn more about using functions in Python

ArcGIS Online / Portal functions

FunctionDescription

ClearCredentials

The ClearCredentials function removes ArcGIS Server credential information from a client machine to disable access to secured services.

GetActivePortalURL

Returns the URL of the active portal.

GetPortalDescription

GetPortalDescription is used to return the view of the portal as seen by the current user, anonymous or logged in. It includes information such as the name, logo, featured items, and supported protocols (HTTP versus HTTPS) for this portal. If the user is not logged in, this call will return the default view of the portal. If the user is logged in, the view of the returned portal will be specific to the organization to which the user belongs. The default view of the portal is dependent on the culture of the user, which is obtained from the user's profile.

GetPortalInfo

The GetPortalInfo function returns a dictionary that contains information on available portals.

GetSigninToken

Returns token information when signed in to ArcGIS.com or a local portal.

ImportCredentials

The ImportCredentials function imports credentials from a GIS Server connection file for ArcGIS Server nontoken-based secured services.

ListPortalURLs

The ListPortalURLs function returns a list of available portal URLs.

SignInToPortal

The SignInToPortal function allows you to sign in to a portal.

Cursor functions

FunctionDescription

InsertCursor

Inserts rows into a feature class, shapefile, or table. InsertCursor returns an enumeration object that hands out Row objects.

SearchCursor

The SearchCursor function establishes a read-only cursor on a feature class or table. SearchCursor can be used to iterate through Row objects and extract field values. The search can optionally be limited by a where clause or by field and optionally sorted.

UpdateCursor

The UpdateCursor function creates a cursor that allows you to update or delete rows on the specified feature class, shapefile, or table. The cursor places a lock on the data that will remain until either the script completes or the update cursor object is deleted.

Data store functions

FunctionDescription

AddDataStoreItem

Registers a folder or database with an ArcGIS Server site.

ListDataStoreItems

Returns a list of the folders or databases registered with an ArcGIS Server site.

RemoveDataStoreItem

Unregisters a folder or database from an ArcGIS Server site.

ValidateDataStoreItem

Validates whether a folder or database has been successfully registered with an ArcGIS Server site.

Describing data functions

Function

Describe

The Describe function returns a Describe object with multiple properties, such as data type, fields, indexes, and many others. Its properties are dynamic, meaning that depending on what data type is described, different describe properties will be available for use.

Environment functions

FunctionDescription

ClearEnvironment

Resets a specific environment setting to its default.

GetSystemEnvironment

Gets the specified system environment variable value, such as "TEMP".

ListEnvironments

Returns a list of geoprocessing environment names.

ResetEnvironments

Resets all environment settings to their default settings.

Field functions

FunctionDescription

AddFieldDelimiters

Adds field delimiters to a field name to allow for use in SQL expressions.

ParseFieldName

Parses a fully qualified field name into its components (database, owner name, table name, and field name) depending on the workspace. ParseFieldName returns a string that includes the parsed table name and contains the database, owner, table, and field names, separated by commas. The workspace must be a personal, file, or enterprise geodatabase.

ValidateFieldName

Takes a string (field name) and a workspace path and returns a valid field name based on name restrictions in the output geodatabase. All invalid characters in the input string will be replaced with an underscore (_). The field name restrictions depend on the specific database used (Structured Query Language [SQL] or Oracle).

General functions

FunctionDescription

AlterAliasName

Updates the alias name for a table or feature class.

Command

Executes a geoprocessing tool as a single string.

CreateObject

Creates geoprocessing objects. The extra arguments can be used to specify additional requirements for the object creation such as the number of columns in the ValueTable object.

CreateRandomValueGenerator

Creates a new random number generator.

ListPrinterNames

Returns a list of available printers on the local computer.

Usage

Returns the syntax for the specified tool or function.

General data functions

FunctionDescription

CreateScratchName

Creates a unique scratch path name for the specified data type. If no workspace is given the current workspace is used.

CreateUniqueName

Creates a unique name in the specified workspace by appending a number to the input name. This number is increased until the name is unique. If no workspace is specified, the current workspace is used.

Exists

Determines the existence of the specified data object. This function tests for the existence of various data types including feature classes, tables, datasets, shapefiles, workspaces, layers, and files. The function returns a Boolean indicating whether the element exists.

ParseTableName

Parses a table name into its components (database, owner, table) depending on the workspace. ParseTableName returns a string containing the parsed table name, with the database name, owner name, and table name, separated by commas. This workspace must be a personal, file, or enterprise geodatabase.

TestSchemaLock

Tests if a schema lock can be acquired for a feature class, table, or feature dataset. Tools that alter schema will require a schema lock to be placed on the input data. The Add Field tool is an example of such a tool. If the tool requires a schema lock and is unable to aquire one at the time of execution, an appropriate error message is returned. Scripts that use such tools should test if a schema lock can be acquired on the input data. The TestSchemaLock function will not actually apply a schema lock on the input data, but will return a Boolean.

ValidateTableName

Takes a table name and a workspace path and returns a valid table name for the workspace. An underscore "_" will replace any invalid character found in the table name and will honor the name restrictions for the workspace. The table name restrictions depend on the specific RDBMS used.

Geodatabase administration functions

FunctionDescription

AcceptConnections

Allows an administrator to enable or disable the ability of nonadministrative users to make connections to an enterprise geodatabase.

DisconnectUser

Allows an administrator to disconnect users who are currently connected to an enterprise geodatabase.

ListUsers

Returns a list of named tuples containing information for users who are connected to an enterprise geodatabase.

Geometry functions

FunctionDescription

AsShape

Converts Esri JSON or GeoJSON geometry to ArcPy geometry, and Esri JSON feature sets to ArcPy feature sets. GeoJSON is a geospatial data interchange format for encoding geographic data structures.

FromCoordString

Converts a coordinate system notation string to a PointGeometry object in WGS84 coordinates.

FromGeohash

Converts a geohash string to an Extent object in WGS 1984 coordinates that represents the corresponding bounding box in the geohash grid.

FromWKB

Create a new geometry object from a well-known binary (WKB) string stored in a bytearray.

FromWKT

Create a new Geometry object from a well-known text (WKT) string.

Licensing and installation functions

FunctionDescription

CheckExtension

Checks to see if a license is available to be checked out for a specific type of extension.

CheckInExtension

Returns the license to the License Manager so other applications can use it.

CheckOutExtension

Retrieves the license from the License Manager.

CheckProduct

Checks to see if the requested license is available.

GetInstallInfo

The GetInstallInfo function returns a dictionary that contains information on the installation.

ListInstallations

The ListInstallations function returns a list of installation types (server, desktop, engine, arcgispro).

ProductInfo

Returns the current product license.

Listing data functions

FunctionDescription

ListDatasets

Returns a list of datasets in the current workspace. Search conditions can be specified for the dataset name and dataset type to limit the list that is returned.

ListFeatureClasses

Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset.

ListFields

Returns a list of fields in a feature class, shapefile, or table in a specified dataset. The returned list can be limited with search criteria for name and field type and will contain field objects.

ListFiles

Returns a list of files in the current workspace.

ListIndexes

Returns a list of the indexes in a feature class, shapefile, or table in a specified dataset.

ListRasters

Returns a list of the rasters in the current workspace.

ListTables

Returns a list of tables in the current workspace.

ListVersions

Lists the versions the connected user has permission to use.

ListWorkspaces

Returns a list of workspaces in the current workspace.

Logging functions

FunctionDescription

GetLogHistory

Determines whether history logging is active.

GetLogMetadata

Determines whether geoprocessing operations are written to dataset metadata.

SetLogHistory

Controls whether information about the execution of geoprocessing tools is written to an external log file.

SetLogMetadata

Controls whether geoprocessing tool input and output datasets' metadata is updated to include the tool name, parameters, when the tool was run, and other information.

Message and error handling functions

FunctionDescription

AddError

Adds an error message (severity of 2) to the messages of a script tool or Python toolbox tool.

AddIDMessage

Allows you to use system messages with a script tool.

AddMessage

Adds a custom informative message (severity of 0) to the messages of a script tool or Python toolbox tool.

AddReturnMessage

Sets the return message of a script tool as an output message by index.

AddWarning

Adds a custom warning message (severity of 1) to the messages of a script tool or Python toolbox tool.

GetIDMessage

Get the string of the error or warning ID message.

GetMaxSeverity

Gets the maximum severity returned from the last executed tool.

GetMessage

Returns a geoprocessing tool message by its index position.

GetMessageCount

Returns a numeric count of all the returned messages from the last executed command.

GetMessages

Returns the geoprocessing messages from a tool by a specified severity level.

GetReturnCode

Return the message error code by index.

GetSeverity

Gets the severity code (0, 1, 2) of the specified message by index.

GetSeverityLevel

Returns the severity level. The severity level is used to control how geoprocessing tools throw exceptions.

SetSeverityLevel

Used to control how geoprocessing tools throw exceptions.

Parameter functions

FunctionDescription

CopyParameter

Copies the specified parameter by index to another parameter in the script tool. The specified parameters must be of the same data type.

GetArgumentCount

Returns the number of arguments passed to the script.

GetParameter

From the parameter list, select the desired parameter by its index value. The parameter is returned as an object.

GetParameterAsText

Gets the specified parameter as a text string by its index position from the list of parameters.

GetParameterCount

Returns a count of the parameter values for the specified tool. If the tool is contained in a custom toolbox, use ImportToolbox to access the custom tool.

GetParameterInfo

Returns a list of parameter objects for a given tool and is commonly used in a script tool's ToolValidator class.

GetParameterValue

For a specified tool name, returns the default value of the desired parameter.

SetParameter

Sets a specified parameter property by index using an object. This function is used to pass objects from a script to a script tool. If you need to pass a string, use the SetParameterAsText function.

SetParameterAsText

Gets the specified parameter as a text string by its index position from the list of parameters.

SetParameterSymbology

Sets the symbology properties of the specified output parameter of a script tool.

Progress dialog functions

FunctionDescription

ResetProgressor

Resets the progressor to its initial state.

SetProgressor

Establishes a progressor object to support progress information to be displayed in the Geoprocessing pane. The appearance of the progressor can be controlled by choosing either the default progressor or the step progressor.

SetProgressorLabel

Updates the progressor label in the Geoprocessing pane.

SetProgressorPosition

Updates the progressor status bar in the Geoprocessing pane.

Publishing functions

FunctionDescription

CreateGeocodeSDDraft

The function converts a locator into a Service Definition Draft (.sddraft) file, which can be used to create a service definition for publishing a geocode service.

CreateGPSDDraft

The function converts Result objects and result files (.rlt) into Service Definition Draft (.sddraft) files.

CreateImageSDDraft

The CreateImageSDDraft function is the first step to automating the publishing of a mosaic dataset or raster dataset as an Image Service using ArcPy. The output created from the CreateImageSDDraft is a Service Definition Draft (.sddraft) file, which is a combination of a mosaic dataset in the geodatabase or a raster dataset, information about the server, and a set of service properties. This service definition draft can be staged as service definition then uploaded to a specified ArcGIS server as an image service.

Raster functions

FunctionDescription

GetImageEXIFProperties

Returns EXIF header information from a geotagged image.

NumpyArrayToRaster

Converts a NumPy array to a raster.

RasterToNumPyArray

Converts a raster to a NumPy array.

Spatial reference and transformation functions

FunctionDescription

GenerateOptimalCoordinateSystem

Generates a SpatialReference object with a custom projected coordinate system optimal for the specified extent and intended purpose of your map or analysis.

ListSpatialReferences

Returns a list of available spatial reference names for use as an argument to the SpatialReference class.

ListTransformations

Returns a list of valid transformation methods. An extent can be used to narrow the list of valid transformation methods for a specific geographic area.

Tool and toolbox functions

FunctionDescription

AddToolbox

Imports the specified toolbox into ArcPy, allowing for access to the toolbox's associated tools.

DecryptPYT

Decrypt an encrypted Python toolbox file.

EncryptPYT

Encrypts a Python toolbox file.

ImportToolbox

Imports the specified toolbox into ArcPy, allowing for access to the toolbox's associated tools.

IsSynchronous

Determines if a tool is running synchronous or asynchronous. When a tool is synchronous, the results are automatically returned, but no other action may be taken until the tool has completed. All non-server tools are synchronous. Server tools may be asynchronous, meaning that once the tool has been submitted to the server, other functionality can be run without waiting, and the results must be explicitly requested from the server.

ListToolboxes

Returns a list of toolboxes.

ListTools

Returns a list of geoprocessing tools.

RemoveToolbox

Removes the specified toolbox, either by specifying its path or referencing its alias. Removes the specified toolbox from the current geoprocessing session. Server toolboxes can also be removed using a semicolon delimiter.

Related topics