FieldInfo (arcpy)
摘要
为图层和表视图提供字段信息方法和属性。
语法
属性
| 属性 | 说明 | 数据类型 |
| count (只读) |
The field count. | Integer |
方法概述
| 方法 | 说明 |
| addField (field_name, new_field_name, visible, split_rule) |
添加字段条目信息 |
| exportToString () |
Exports the object to its string representation. |
| findFieldByName (field_name) |
Finds the field index by field name |
| findFieldByNewName (field_name) |
Finds the field index by new field name. |
| getFieldName (index) |
Gets the field name from the table by index position. |
| getNewName (index) |
Gets the new field name from the table by index position. |
| getSplitRule (index) |
Gets the split rule from the table by index position. |
| getVisible (index) |
Gets the visible flag from the table by index position. |
| loadFromString (string) |
Restore the object using its string representation. The exportToString method can be used to create a string representation. |
| removeField (index) |
Removes the field info entry from a table. |
| setFieldName (index, field_name) |
Sets the field name into the table. |
| setNewName (index, new_field_name) |
Sets the new field name into the table. |
| setSplitRule (index, rule) |
Sets the split rule into the table. |
| setVisible (index, visible) |
Set the visible flag of a field on the table. |
方法
| 参数 | 说明 | 数据类型 |
field_name |
The field name from the input feature class or table. | String |
new_field_name |
Sets the field name for the new layer or table view. | String |
visible |
Sets whether the field is visible or hidden.
| String |
split_rule |
Sets the behavior of an attribute's values when a feature is split.
| String |
| 数据类型 | 说明 |
| String |
The string representation of the object. |
| 参数 | 说明 | 数据类型 |
field_name |
The field name used to find its index position | String |
| 数据类型 | 说明 |
| Integer |
The index position |
| 参数 | 说明 | 数据类型 |
field_name |
The new field name used to find its index position. | String |
| 数据类型 | 说明 |
| Integer |
The index position. |
| 参数 | 说明 | 数据类型 |
index |
The index position. | Integer |
| 数据类型 | 说明 |
| String |
The field name. |
| 参数 | 说明 | 数据类型 |
index |
The index position. | Integer |
| 数据类型 | 说明 |
| String |
The new field name. |
| 参数 | 说明 | 数据类型 |
index |
The index position. | String |
| 数据类型 | 说明 |
| String |
The split rule.
|
| 参数 | 说明 | 数据类型 |
index |
The index position. | String |
| 数据类型 | 说明 |
| String |
The visible flag.
|
| 参数 | 说明 | 数据类型 |
string |
The string representation of the object. | String |
| 参数 | 说明 | 数据类型 |
index |
The index position of the field info object. | Integer |
| 参数 | 说明 | 数据类型 |
index |
The index position. | Integer |
field_name |
The field name to set into the table. | String |
| 参数 | 说明 | 数据类型 |
index |
The index position. | None |
new_field_name |
The new field name to set into the table. | String |
| 参数 | 说明 | 数据类型 |
index |
The index position. | Integer |
rule |
The split rule to set into the table.
| String |
| 参数 | 说明 | 数据类型 |
index |
The index position. | Integer |
visible |
The visible policy to set into the table.
| String |
代码实例
显示要素图层的 FieldInfo 属性。
import arcpy
feature_class = "c:/Data/wells.shp"
layer = "temp_layer"
arcpy.MakeFeatureLayer_management(feature_class, layer)
# Create a describe object
desc = arcpy.Describe(layer)
# If a feature layer, continue
if desc.dataType == "FeatureLayer":
# Create a fieldinfo object
field_info = desc.fieldInfo
# Use the count property to iterate through all the fields
for index in xrange(0, field_info.count):
# Print fieldinfo properties
print("Field Name: {0}".format(field_info.getFieldName(index)))
print("\tNew Name: {0}".format(field_info.getNewName(index)))
print("\tSplit Rule: {0}".format(field_info.getSplitRule(index)))
print("\tVisible: {0}".format(field_info.getVisible(index)))