Accessing data sources in Python

Geoprocessing tools and other ArcPy functionality usually have input parameters that define the dataset or datasets that are typically used to generate new output data.

Input data is frequently accessed via a data path. If the input is a file type, such as a text file, the path is the same as that in File Explorer (Windows Explorer). A catalog path is a path that only ArcGIS recognizes, for example, a feature class in a file geodatabase. The D:\Data\Final\Infrastructure.gdb\EastValley\powerlines path refers to the powerlines feature class in the EastValley feature dataset in the Infrastructure file geodatabase. This is not a valid system path for the Windows operating system, because the Infrastructure.gdb folder does not contain a file named Infrastructure.

Feature services

When using ArcPy to access web feature layers, you can open individual layers and tables by providing the URL to the feature service sublayer referenced by the layer. To access the workspace for the web feature layer, provide the URL to the service. This syntax can be used in any tool or function referenced in your scripts.

Sublayer example
import arcpy
layer_name = "Permits"
featureLayer = arcpy.MakeFeatureLayer_management("https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer/0", 
                                                 layer_name)
Workspace example
import arcpy
arcpy.env.workspace = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/PoolPermits/FeatureServer"
featureClasses = arcpy.ListFeatureClasses()

Dans cette rubrique
  1. Feature services