ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

使用字段和索引

在描述要素类和表时,要素类和表具有一个用于返回 Field 对象列表的 fields 属性,以及一个用于返回 Index 对象列表的 indexes 属性。每个字段或索引对象都具有大量可用来研究该对象的属性。另外,使用 ListFields 和 ListIndexes 函数也可以创建相同的列表。

ListFields(dataset, wild_card, field_type)

返回在输入值中找到的字段的列表

ListIndexes(dataset, wild_card)

返回在输入值中找到的属性索引的列表

列表函数

下面的示例描述了如何创建字段列表以及循环浏览列表内容以查找特定的字段。

import arcpy
fc = 'D:/St_Johns/data.gdb/roads'
# Get a list of field objects
fields = arcpy.ListFields(fc, 'Flag')
for field in fields:
    # Check the field name, perform a calculation when finding the field 'Flag'
    if field.name == 'Flag':
        # Set the value for the field and exit loop
        arcpy.CalculateField_management(fc, 'Flag', '1')
        break

以下列出了字段和索引对象的属性:

属性说明

name

字段的名称。

aliasName

字段的别名。

domain

关联属性域的名称。

editable

字段可编辑时为 True。

isNullable

字段可为空时为 True。

required

字段为必填字段时为 True。

length

字段的长度。

type

SmallInteger、Integer、Single、Double、String、Date、OID、Geometry、BLOB。

scale

字段的小数位数。

precision

字段的精度。

字段属性

属性说明

name

索引的名称。

isAscending

索引按升序排序时为 True。

isUnique

索引唯一时为 True。

fields

Field 对象的列表。这与使用 Describe fields 属性时相同。

索引属性

提示:

ListFields 和 ListIndexes 可用来基于名称和类型限制结果。

相关主题

  • ListFields
  • ListIndexes
  • 创建数据列表

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明