Skip to main content

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 and Portal for ArcGIS functions

Function

Description

ClearCredentials

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

CreateAGSServerConnection

The CreateAGSServerConnection function creates an ArcGIS Server connection file that can be used to access an ArcGIS Server site.

GetActivePortalURL

The GetActivePortalURL function returns the URL of the active portal.

GetPortalDescription

The GetPortalDescription function returns a dictionary of portal information.

GetPortalInfo

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

GetSigninToken

The GetSigninToken function 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

Function

Description

InsertCursor

The InsertCursor function inserts rows of attribute values into a specified feature class or table.

SearchCursor

The SearchCursor function returns rows of attribute values from a feature class or table.

UpdateCursor

The UpdateCursor function updates or deletes rows of attribute values from a feature class or table.

Data store functions

Function

Description

AddDataStoreItem

The AddDataStoreItem function registers a folder or database with an ArcGIS Server site.

ListDataStoreItems

The ListDataStoreItems function returns a list of the folders or databases registered with an ArcGIS Server site.

RemoveDataStoreItem

The RemoveDataStoreItem function unregisters a folder or database from an ArcGIS Server site.

ValidateDataStoreItem

The ValidateDataStoreItem function validates whether a folder or database has been successfully registered with an ArcGIS Server site.

Describing data functions

Function

Describe

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

Environment functions

Function

Description

ClearEnvironment

The ClearEnvironment function resets a specific environment setting to its default.

GetSystemEnvironment

The GetSystemEnvironment function gets a specified system environment variable value, such as TEMP.

ListEnvironments

The ListEnvironments function returns a list of geoprocessing environment names.

ResetEnvironments

The ResetEnvironments function resets all environment settings to their default settings.

Field functions

Function

Description

AddFieldDelimiters

The AddFieldDelimiters function adds field delimiters to a field name for use in SQL queries.

ParseFieldName

The ParseFieldName function 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 file or enterprise geodatabase.

ValidateFieldName

The ValidateFieldName function returns a valid field name for a database based on a field name and a path to a database. All invalid characters in the input field name are replaced with an underscore. The field name restrictions depend on the type of database.

General functions

Function

Description

AIOFileOpen

The AIOFileOpen function opens a local or cloud file handle that supports context manager protocol.

CreateRandomValueGenerator

The CreateRandomValueGenerator function creates a random number generator.

ListPrinterNames

The ListPrinterNames function returns a list of available printers on the local computer.

RefreshLayer

The RefreshLayer function refreshes the map views containing the specified layers.

General data functions

Function

Description

AlterAliasName

The AlterAliasName function updates the alias name for a table or feature class.

CreateScratchName

The CreateScratchName function creates a unique scratch path name for the specified data type.

CreateUniqueName

The CreateUniqueName function creates a unique name for the specified workspace by appending a number to the input name. This number is incremented until the name is unique.

Exists

The Exists function determines the existence of the specified data object.

IsBeingEdited

The IsBeingEdited function determines whether the given dataset or workspace is in an edit session.

ParseTableName

The ParseTableName function parses a table name into its components (database, owner, table) depending on the workspace.

TestSchemaLock

The TestSchemaLock function tests if a schema lock can be acquired for a feature class, table, or feature dataset.

ValidateTableName

The ValidateTableName function returns a valid table name for a workspace based on a table name and a workspace path.

Geodatabase administration functions

Function

Description

AcceptConnections

The AcceptConnections function allows an administrator to enable or disable the ability of nonadministrative users to make connections to an enterprise geodatabase.

DisconnectUser

The DisconnectUser function allows an administrator to disconnect users who are currently connected to an enterprise geodatabase.

ListUsers

The ListUsers function returns a list of named tuples containing information for users who are connected to an enterprise geodatabase.

Geometry functions

Function

Description

AsShape

The AsShape function 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

The FromCoordString function converts a coordinate system notation string to a PointGeometry object in WGS84 coordinates.

FromGeohash

The FromGeohash function converts a geohash string to an Extent object in WGS 1984 coordinates that represents the corresponding bounding box in the geohash grid.

FromWKB

The FromWKB function creates a geometry object from a well-known binary (WKB) string stored as a bytearray or bytes object.

FromWKT

The FromWKT function creates a geometry object from a well-known text (WKT) string.

Licensing and installation functions

Function

Description

CheckExtension

The CheckExtension function checks to see if a license is available to be checked out for a specific type of extension.

CheckInExtension

The CheckInExtension function returns the license to the License Manager so other applications can use it.

CheckOutExtension

The CheckOutExtension function retrieves the license from the License Manager.

CheckProduct

The CheckProduct function checks to see if the requested license is available.

GetInstallInfo

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

ListInstallations

The ListInstallations function returns a list of installation types.

ProductInfo

The ProductInfo function returns the current product license.

Listing data functions

Function

Description

ListDatasets

The ListDatasets function 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

The ListFeatureClasses function returns a list of the feature classes in the current workspace, limited by name, feature type, and optionally, feature dataset.

ListFields

The ListFields function 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

The ListFiles function returns a list of files in the current workspace.

ListIndexes

The ListIndexes function returns a list of the indexes in a feature class, shapefile, or table in a specified dataset.

ListRasterProducts

The ListRasterProducts function returns a list of paths to the raster products associated with a metadata file.

ListRasters

The ListRasters function returns a list of the rasters in the current workspace.

ListTables

The ListTables function returns a list of tables in the current workspace.

ListVersions

The ListVersions function returns a list of versions that the connected user has permission to use.

ListWorkspaces

The ListWorkspaces function returns a list of workspaces in the current workspace.

Logging functions

Function

Description

GetLogHistory

The GetLogHistory function determines whether history logging is active.

GetLogMetadata

The GetLogMetadata function controls whether geoprocessing operations are written to dataset metadata.

SetLogHistory

The SetLogHistory function controls whether information about the operation of geoprocessing tools is written to an external log file.

SetLogMetadata

The SetLogMetadata function 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

Function

Description

AddError

The AddError function adds an error message (severity of 2) to the messages of a script tool or Python toolbox tool.

AddIDMessage

The AddIDMessage function adds system ID messages to the messages of a script tool or Python toolbox tool.

AddMessage

The AddMessage function adds an informative message (severity of 0) to the messages of a script tool or Python toolbox tool.

AddReturnMessage

The AddReturnMessage function sets the return message of a script tool as an output message by index.

AddWarning

The AddWarning function adds a warning message (severity of 1) to the messages of a script tool or Python toolbox tool.

GetAllMessages

The GetAllMessages function returns the message types, return codes, and message strings from the previously run tool.

GetIDMessage

The GetIDMessage function gets the string of the error or warning ID message.

GetMaxSeverity

The GetMaxSeverity function gets the maximum severity returned from the previously run tool.

GetMessage

The GetMessage function returns a geoprocessing tool message by index position.

GetMessageCount

The GetMessageCount function returns a numeric count of all the returned messages from the previously run tool.

GetMessages

The GetMessages function returns the geoprocessing messages from a tool by a specified severity level.

GetReturnCode

The GetReturnCode function returns the message error code for a geoprocessing message.

GetSeverity

The GetSeverity function gets the severity code (0, 1, 2) of the specified message by index.

GetSeverityLevel

The GetSeverityLevel function returns the severity level. The severity level is used to control how geoprocessing tools raise exceptions.

SetMessageLevels

The SetMessageLevels function sets additional categories of informative messages to be returned with geoprocessing tool messages.

SetSeverityLevel

The SetSeverityLevel function controls how geoprocessing tools will raise exceptions in a script.

Packaging functions

Function

Description

GetPackageInfo

The GetPackageInfo function returns a dictionary that contains information about a package file.

Parameter functions

Function

Description

CopyParameter

The CopyParameter function copies the specified parameter by index or parameter name to another parameter in the script tool. The specified parameters must be of the same data type.

GetArgumentCount

The GetArgumentCount function returns the number of arguments passed to the script.

GetParameter

The GetParameter function returns the parameter as an object when you select the desired parameter from the parameter list by its index or its name.

GetParameterAsText

The GetParameterAsText function gets the specified parameter as a text string by its index position or parameter name.

GetParameterCount

The GetParameterCount function returns a count of the parameter values for the specified tool.

GetParameterInfo

The GetParameterInfo function returns a list of parameter objects for a given tool and is commonly used in a script tool's ToolValidator class.

GetParameterValue

The GetParameterValue function returns the default value of a tool parameter. The parameter is specified by either index or parameter name.

SetParameter

The SetParameter function sets a specified parameter property by index or parameter name using an object.

SetParameterAsText

The SetParameterAsText function sets a specified parameter property by index or parameter name using a string value.

SetParameterSymbology

The SetParameterSymbology function sets the symbology properties of the specified output parameter of a script tool by index or parameter name.

Progress dialog functions

Function

Description

ResetProgressor

The ResetProgressor function resets the progressor to its initial state.

SetProgressor

The SetProgressor function establishes a progressor object to support progress information to be displayed in the Geoprocessing pane.

SetProgressorLabel

The SetProgressorLabel function updates the progressor label in the Geoprocessing pane.

SetProgressorPosition

The SetProgressorPosition function updates the progressor status bar in the Geoprocessing pane.

Publishing functions

Function

Description

CreateGeocodeSDDraft

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

CreateGPSDDraft

The CreateGPSDDraft function converts Result objects and result files (.rlt) to a service definition draft file (.sddraft).

CreateImageSDDraft

The CreateImageSDDraft function converts a raster or mosaic dataset to a Service Definition Draft file (.sddraft).

Raster functions

Function

Description

GetImageEXIFProperties

The GetImageEXIFProperties function returns EXIF header information from a geotagged image.

GetSTACInfo

The GetSTACInfo function retrieves information from a SpatioTemporal Asset Catalog (STAC) URL.

NumpyArrayToRaster

The NumpyArrayToRaster function converts a NumPy array to a raster.

RasterToNumPyArray

The RasterToNumPyArray function converts a raster to a NumPy array.

Render

The Render function creates a rendered raster object by applying symbology to the referenced raster dataset.

Spatial reference and transformation functions

Function

Description

GenerateOptimalCoordinateSystem

The GenerateOptimalCoordinateSystem function generates a SpatialReference object with a custom projected coordinate system optimal for the specified extent and intended purpose of the map or analysis.

ListSpatialReferences

The ListSpatialReferences function lists available spatial reference names for use as an argument to the SpatialReference class.

ListTransformations

The ListTransformations function returns a list of valid transformation methods.

Tool and toolbox functions

Function

Description

AddToolbox

The AddToolbox function imports the specified toolbox into ArcPy, allowing for access to the toolbox's associated tools.

Command

The Command function runs a geoprocessing tool as a single string.

CreateObject

The CreateObject function creates a geoprocessing object.

DecryptPYT

The DecryptPYT function decrypts an encrypted Python toolbox file.

EncryptPYT

The EncryptPYT function encrypts a Python toolbox file.

ImportToolbox

The ImportToolbox function imports a geoprocessing toolbox for use in ArcPy, allowing access to the toolbox's associated tools.

IsSynchronous

The IsSynchronous function determines if a tool is running synchronous or asynchronous.

ListToolboxes

The ListToolboxes function returns a list of geoprocessing toolboxes.

ListTools

The ListTools function returns a list of geoprocessing tools.

RemoveToolbox

The RemoveToolbox function removes the specified toolbox, either by specifying its path or referencing its alias, from the current geoprocessing session.

Usage

The Usage function returns the syntax for the specified tool or function.

Unit conversion functions

Function

Description

ArealUnitConversionFactor

The ArealUnitConversionFactor function returns the factor for converting an areal measurement to a different areal unit.

LinearUnitConversionFactor

The LinearUnitConversionFactor function returns the factor for converting a distance measurement to a different linear unit.