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

Removes ArcGIS Server credential information from a client machine to disable access to secured services.

GetActivePortalURL

Returns the URL of the active portal.

GetPortalDescription

Returns a dictionary of portal information.

GetPortalInfo

Returns a dictionary that contains information about available portals.

GetSigninToken

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

ImportCredentials

Imports credentials from a GIS server connection file for ArcGIS Server nontoken-based secured services.

ListPortalURLs

Returns a list of available portal URLs.

SignInToPortal

Allows you to sign in to a portal.

Cursor functions

FunctionDescription

InsertCursor

Inserts rows of attribute values into a specified feature class or table.

SearchCursor

Returns rows of attribute values from a feature class or table.

UpdateCursor

Updates or deletes rows of attribute values from a feature class or table.

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

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

FunctionDescription

ClearEnvironment

Resets a specific environment setting to its default.

GetSystemEnvironment

Gets a 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 file, or enterprise geodatabase.

ValidateFieldName

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

FunctionDescription

AIOFileOpen

Opens a local or cloud file handle that supports context manager protocol.

AlterAliasName

Updates the alias name for a table or feature class.

ArealUnitConversionFactor

Returns the factor for converting an area measurement to a different areal unit.

Command

Runs a geoprocessing tool as a single string.

CreateObject

Creates a geoprocessing object. 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.

IsBeingEdited

Determines whether the given dataset or workspace is in an edit session.

LinearUnitConversionFactor

Returns the factor for converting a distance measurement to a different linear unit.

ListPrinterNames

Returns a list of available printers on the local computer.

RefreshLayer

Refreshes the map views containing the specified layers.

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 for the specified workspace by appending a number to the input name. This number is incremented 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 acquire one when the tool is run, 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

Returns a valid table name for a workspace based on a table name and a workspace path. All invalid characters in the input table name are replaced with an underscore. The table name restrictions depend on the type of database.

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

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

Creates a geometry object from a well-known binary (WKB) string stored as a bytearray or bytes object.

FromWKT

Creates a 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

Returns a dictionary that contains information about the installation.

ListInstallations

Returns a list of installation types.

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

Use system ID messages with a script tool.

AddMessage

Adds an 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 warning message (severity of 1) to the messages of a script tool or Python toolbox tool.

GetAllMessages

Returns the message types, return codes, and message strings from the previously run tool.

GetIDMessage

Get the string of the error or warning ID message.

GetMaxSeverity

Gets the maximum severity returned from the previously run tool.

GetMessage

Returns a geoprocessing tool message by index position.

GetMessageCount

Returns a numeric count of all the returned messages from the previously run tool.

GetMessages

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

GetReturnCode

Returns the message error code for a geoprocessing message.

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.

SetMessageLevels

Sets additional categories of informative messages to be returned with geoprocessing tool messages.

SetSeverityLevel

Controls how geoprocessing tools throw exceptions.

Parameter functions

FunctionDescription

CopyParameter

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

Returns the number of arguments passed to the script.

GetParameter

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

GetParameterAsText

Gets the specified parameter as a text string by its index position or parameter name.

GetParameterCount

Returns a count of the parameter values for the specified tool. If the tool is contained in a custom toolbox, use the ImportToolbox function 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. The parameter is specified by either index or parameter name.

SetParameter

Sets a specified parameter property by index or parameter name 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 or parameter name.

SetParameterSymbology

Sets the symbology properties of the specified output parameter of a script tool by index or parameter name.

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

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

Converts Result objects and result files (.rlt) to a service definition draft file (.sddraft).

CreateImageSDDraft

Converts a raster or mosaic dataset to a Service Definition Draft file (.sddraft).

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.

Render

Creates a rendered raster object by applying symbology to the referenced raster dataset. This function is useful when displaying data in a Jupyter notebook.

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 a geoprocessing toolbox for use in ArcPy, allowing 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.

関連トピック