Geoprocessing tools work with all types of data, such as geodatabase feature classes, shapefiles, rasters, tables, topologies, and networks. Each piece of data has particular properties that can be accessed and used to control the flow of a script or used as the parameters of a tool. For example, the output feature type of the Intersect tool is dependent on the shape type of the data being intersected, that is, point, line, or polygon. When the Intersect tool runs in a script on a list of input datasets, you must be able to determine the shape types of the input datasets so the correct output shape type can be set. You can use the arcpy.Describe and arcpy.da.Describe functions to determine the shape types of all the input datasets.
The arcpy.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 are available for use. The arcpy.da.Describe function returns the same information but as a dictionary.
Using Describe, a dataset's properties can be determined and used to make decisions. For instance, in the following example, the script uses Describe to evaluate the shape type (polyline, polygon, point, and so on) of input data and determine which geoprocessing tool is appropriate.
import arcpy
inFC = arcpy.GetParameterAsText(0)
outFC = arcpy.GetParameterAsText(1)
# Describe a feature class using arcpy.Describe
desc = arcpy.Describe(inFC)
# If the shapeType is Polygon convert the data to polylines using the
# FeatureToLine tool, otherwise just copy the data using the CopyFeatures tool.
if desc.shapeType == "Polygon":
arcpy.FeatureToLine_management(inFC, outFC)
else:
arcpy.CopyFeatures_management(inFC, outFC)
Similarly, arcpy.da.Describe can be used for the same purpose. In the following example, the dictionary returned by arcpy.da.Describe is used to evaluate the shape type.
import arcpy
inFC = arcpy.GetParameterAsText(0)
outFC = arcpy.GetParameterAsText(1)
# Describe a feature class using arcpy.da.Describe
desc = arcpy.da.Describe(inFC)
# If the shapeType is Polygon convert the data to polylines using the
# FeatureToLine tool, otherwise just copy the data using the CopyFeatures tool.
if desc['shapeType'] == "Polygon":
arcpy.FeatureToLine_management(inFC, outFC)
else:
arcpy.CopyFeatures_management(inFC, outFC)
Describe properties are organized into a series of property groups. Any particular dataset acquires the properties of at least one of these groups. For instance, if describing a geodatabase feature class, you could access properties from the Geodatabase Feature Class, Feature Class, Table, and Dataset property groups. All data, regardless of the data type, always acquires the generic Describe object properties.
- Eigenschaften des Describe-Objekts
- Eigenschaften des ArcInfo Workstation-Elements
- ArcInfo Workstation-Tabellen
- Attributregeleigenschaften
- BIM-Datei-Workspace-Eigenschaften
- CAD-Zeichnungs-Dataset-Eigenschaften
- CAD-Feature-Class-Eigenschaften
- Coverage-Feature-Class-Eigenschaften
- Coverage-Eigenschaften
- Dataset-Eigenschaften
- dBASE-Tabelleneigenschaften
- Editor-Tracking-Eigenschaften
- Feature-Class-Eigenschaften
- Feldgruppeneigenschaften
- Dateieigenschaften
- Ordnereigenschaften
- Geodatabase-Feature-Class-Eigenschaften
- Geodatabase-Tabelleneigenschaften
- Eigenschaften von "Geometrisches Netzwerk"
- Eigenschaften geostatistischer Layer
- LAS-Dataset-Eigenschaften
- Layer-Eigenschaften
- Location-Referencing-Dataset-Eigenschaften
- Kartendokumenteigenschaften
- Mosaik-Dataset-Eigenschaften
- Network Analyst-Layer-Eigenschaften
- Netzwerk-Dataset-Eigenschaften
- Parcel-Fabric-Eigenschaften
- Parcel Fabric For ArcMap-Eigenschaften
- Projektionsdateieigenschaften
- Raster-Band-Eigenschaften
- Raster-Katalog-Eigenschaften
- Raster-Dataset-Eigenschaften
- Datensatz- und Feature-Set-Eigenschaften
- Beziehungsklasseneigenschaften
- Repräsentationsklasseneigenschaften
- Schematic-Dataset-Eigenschaften
- Schematic-Diagrammeigenschaften
- Schematic-Ordnereigenschaften
- SDC-Feature-Class-Eigenschaften
- Shapefile-Feature-Class-Eigenschaften
- Tabelleneigenschaften
- Tabellensichteigenschaften
- Textdateieigenschaften
- TIN-Eigenschaften
- Werkzeugeigenschaften
- Toolbox-Eigenschaften
- Topologie-Eigenschaften
- Verfolgungsnetzeigenschaften
- Versorgungsnetzeigenschaften
- VPF-Coverage-Eigenschaften
- VPF-Feature-Class-Eigenschaften
- VPF-Tabelleneigenschaften
- Workspace-Eigenschaften