图层属性 (arcpy)

摘要

Describe 函数可返回图层的以下属性。同时还支持数据集属性及图层所引用的数据类型的属性。例如,引用要素类的图层可以访问要素类属性,而引用栅格数据集的图层可以访问栅格数据集属性

属性

属性说明数据类型
dataElement
(只读)

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

Describe
featureClass
(只读)

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

Describe
FIDSet
(只读)

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

String
fieldInfo
(只读)

The FieldInfo object (property set) of the layer.

FieldInfo
layer
(只读)

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

Describe
nameString
(只读)

The name of the layer.

String
table
(只读)

The Describe object of the Table within a FeatureLayer.

Describe
whereClause
(只读)

The layer's definition query WHERE clause.

String

代码实例

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"
5/10/2014