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:
- Charts module (arcpy.charts)
- Data Access module (arcpy.da)
- Geocoding module (arcpy.geocoding)
- Image Analysis module (arcpy.ia)
- Mapping module (arcpy.mp)
- Metadata module (arcpy.metadata)
- Network Analyst modules (arcpy.nax and arcpy.na)
- Sharing module (arcpy.sharing)
- Spatial Analyst module (arcpy.sa)
- Workflow Manager (Classic) module (arcpy.wmx)
Learn more about using functions in Python
ArcGIS Online / Portal functions
Function | Description |
---|---|
Removes ArcGIS Server credential information from a client machine to disable access to secured services. | |
Returns the URL of the active portal. | |
Returns a dictionary of portal information. | |
Returns a dictionary that contains information about available portals. | |
Returns token information when signed in to ArcGIS.com or a local portal. | |
Imports credentials from a GIS server connection file for ArcGIS Server nontoken-based secured services. | |
Returns a list of available portal URLs. | |
Allows you to sign in to a portal. |
Cursor functions
Function | Description |
---|---|
Inserts rows of attribute values into a specified feature class or table. | |
Returns rows of attribute values from a feature class or table. | |
Updates or deletes rows of attribute values on a specified feature class or table. |
Data store functions
Function | Description |
---|---|
Registers a folder or database with an ArcGIS Server site. | |
Returns a list of the folders or databases registered with an ArcGIS Server site. | |
Unregisters a folder or database from an ArcGIS Server site. | |
Validates whether a folder or database has been successfully registered with an ArcGIS Server site. |
Describing data functions
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 |
---|---|
Resets a specific environment setting to its default. | |
Gets the specified system environment variable value, such as "TEMP". | |
Returns a list of geoprocessing environment names. | |
Resets all environment settings to their default settings. |
Field functions
Function | Description |
---|---|
Adds field delimiters to a field name to allow for use in SQL expressions. | |
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. | |
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
Function | Description |
---|---|
Updates the alias name for a table or feature class. | |
Executes a geoprocessing tool as a single string. | |
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. | |
Creates a new random number generator. | |
Returns a list of available printers on the local computer. | |
Returns the syntax for the specified tool or function. |
General data functions
Function | Description |
---|---|
Creates a unique scratch path name for the specified data type. If no workspace is given the current workspace is used. | |
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. | |
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. | |
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. | |
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. | |
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
Function | Description |
---|---|
Allows an administrator to enable or disable the ability of nonadministrative users to make connections to an enterprise geodatabase. | |
Allows an administrator to disconnect users who are currently connected to an enterprise geodatabase. | |
Returns a list of named tuples containing information for users who are connected to an enterprise geodatabase. |
Geometry functions
Function | Description |
---|---|
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. | |
Converts a coordinate system notation string to a PointGeometry object in WGS84 coordinates. | |
Converts a geohash string to an Extent object in WGS 1984 coordinates that represents the corresponding bounding box in the geohash grid. | |
Creates a geometry object from a well-known binary (WKB) string stored as a bytearray or bytes object. | |
Create a new Geometry object from a well-known text (WKT) string. |
Licensing and installation functions
Function | Description |
---|---|
Checks to see if a license is available to be checked out for a specific type of extension. | |
Returns the license to the License Manager so other applications can use it. | |
Retrieves the license from the License Manager. | |
Checks to see if the requested license is available. | |
Returns a dictionary that contains information about the installation. | |
Returns a list of installation types. | |
Returns the current product license. |
Listing data functions
Function | Description |
---|---|
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. | |
Returns a list of the feature classes in the current workspace, limited by name, feature type, and optional feature dataset. | |
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. | |
Returns a list of files in the current workspace. | |
Returns a list of the indexes in a feature class, shapefile, or table in a specified dataset. | |
Returns a list of the rasters in the current workspace. | |
Returns a list of tables in the current workspace. | |
Lists the versions the connected user has permission to use. | |
Returns a list of workspaces in the current workspace. |
Logging functions
Function | Description |
---|---|
Determines whether history logging is active. | |
Determines whether geoprocessing operations are written to dataset metadata. | |
Controls whether information about the execution of geoprocessing tools is written to an external log file. | |
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 |
---|---|
Adds an error message (severity of 2) to the messages of a script tool or Python toolbox tool. | |
Use system ID messages with a script tool. | |
Adds a custom informative message (severity of 0) to the messages of a script tool or Python toolbox tool. | |
Sets the return message of a script tool as an output message by index. | |
Adds a custom warning message (severity of 1) to the messages of a script tool or Python toolbox tool. | |
Get the string of the error or warning ID message. | |
Gets the maximum severity returned from the last executed tool. | |
Returns a geoprocessing tool message by its index position. | |
Returns a numeric count of all the returned messages from the last executed command. | |
Returns the geoprocessing messages from a tool by a specified severity level. | |
Return the message error code by index. | |
Gets the severity code (0, 1, 2) of the specified message by index. | |
Returns the severity level. The severity level is used to control how geoprocessing tools throw exceptions. | |
Used to control how geoprocessing tools throw exceptions. |
Parameter functions
Function | Description |
---|---|
Copies the specified parameter by index to another parameter in the script tool. The specified parameters must be of the same data type. | |
Returns the number of arguments passed to the script. | |
From the parameter list, select the desired parameter by its index value. The parameter is returned as an object. | |
Gets the specified parameter as a text string by its index position from the list of parameters. | |
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. | |
Returns a list of parameter objects for a given tool and is commonly used in a script tool's ToolValidator class. | |
For a specified tool name, returns the default value of the desired parameter. | |
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. | |
Gets the specified parameter as a text string by its index position from the list of parameters. | |
Sets the symbology properties of the specified output parameter of a script tool. |
Progress dialog functions
Function | Description |
---|---|
Resets the progressor to its initial state. | |
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. | |
Updates the progressor label in the Geoprocessing pane. | |
Updates the progressor status bar in the Geoprocessing pane. |
Publishing functions
Function | Description |
---|---|
Converts a locator to a Service Definition Draft file (.sddraft) that can be used to create a service definition for publishing a geocode service. | |
Converts Result objects and result files (.rlt) to a Service Definition Draft file (.sddraft). | |
Converts a raster or mosaic dataset to a Service Definition Draft file (.sddraft). |
Raster functions
Function | Description |
---|---|
Returns EXIF header information from a geotagged image. | |
Converts a NumPy array to a raster. | |
Converts a raster to a NumPy array. | |
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
Function | Description |
---|---|
Generates a SpatialReference object with a custom projected coordinate system optimal for the specified extent and intended purpose of your map or analysis. | |
Returns a list of available spatial reference names for use as an argument to the SpatialReference class. | |
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
Function | Description |
---|---|
Imports the specified toolbox into ArcPy, allowing for access to the toolbox's associated tools. | |
Decrypt an encrypted Python toolbox file. | |
Encrypts a Python toolbox file. | |
Imports the specified toolbox into ArcPy, allowing for access to the toolbox's associated tools. | |
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. | |
Returns a list of toolboxes. | |
Returns a list of geoprocessing tools. | |
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. |
Rubriques connexes
Vous avez un commentaire à formuler concernant cette rubrique ?