Layer properties

Summary

The Describe function returns the following properties for Layers. Dataset Properties are also supported, as well as the properties of the data type, the layer references. For example, a layer that references a feature class will have access to FeatureClass Properties, while a layer that references a raster dataset will have access to Raster Dataset Properties.

Properties

PropertyExplanationData Type
dataElement
(Read Only)

The Describe object of the data source to which the layer refers.

Object
featureClass
(Read Only)

The Describe object of the feature class associated with the feature layer.

Object
FIDSet
(Read Only)

A semicolon-delimited string of selected feature IDs (record numbers).

String
fieldInfo
(Read Only)

The FieldInfo object (property set) of the layer.

FieldInfo
layer
(Read Only)

The Describe object of the Layer within a .lyr file.

Object
nameString
(Read Only)

The name of the layer.

String
table
(Read Only)

The Describe object of the Table within a FeatureLayer.

Object
whereClause
(Read Only)

The layer's definition query WHERE clause.

String

Code Sample

Layer properties example (stand-alone script)

The following stand-alone script displays some layer properties from an in-memory feature layer.

import arcpy

# Create an in memory feature layer from a feature class.
#
arcpy.MakeFeatureLayer_management(
        "C:/data/chesapeake.gdb/bayshed",
        "mainlines_layer")

# Create a Describe object from the feature layer.
#
desc = arcpy.Describe("mainlines_layer")

# Print some properties of the feature layer, and its featureclass.
#
print "Name String:        " + desc.nameString
print "Where Clause:       " + desc.whereClause
print "Feature class type: " + desc.featureClass.featureType
Layer properties example 2(stand-alone script)

The following stand-alone script displays some layer properties from a .lyr file.

import arcpy


# Create a Describe object from a .lyr file.
#
desc = arcpy.Describe("c:/data/water_pipes.lyr")

# Print some properties of the feature layer
#
print "Name String:        " + desc.nameString
print "Where Clause:       " + desc.whereClause

# Find out if the layer represents a feature class
if desc.dataElement.dataType == "FeatureClass":
    print "Feature class:      " + desc.dataElement.catalogPath
    print "Feature class Type: " + desc.featureClass.featureType
else:
    print "Not a regular feature class"

10/28/2011