Index (arcpy)

摘要

索引对象包含有关表索引的信息。存在两种索引类型:空间与属性。空间索引存在于要素类的 shape 字段中。

讨论

无法直接创建索引对象。可通过 ListIndexesDescribe 功能访问索引对象。

属性

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

A Python List of field objects for the index.

Field
isAscending
(只读)

The isAscending state: True if the index is sorted in ascending order.

Boolean
isUnique
(只读)

The isUnique state: True if the index is unique.

Boolean
name
(只读)

The name of the index.

String

代码实例

索引示例

显示指定表的索引属性。

import arcpy

feature_class = "c:/data/well.shp"

# Create a list of indexes using the ListIndexes function
indexes = arcpy.ListIndexes(feature_class)

# Iterate through the list of indexes
for index in indexes:
    # Print index properties
    print("Name: {0}".format(index.name))
    print("\tType            : {0}".format(index.isAscending))
    print("\tScale           : {0}".format(index.isUnique))
    print("\tNumber of fields: {0}".format(len(index.fields)))

相关主题

5/10/2014