FieldInfo
サマリー
Provides field info methods and properties for layer and table views.
ディスカッション
The FieldInfo object does not support the renaming of fields when the object is used as input to a geoprocessing tool.
構文
FieldInfo()
プロパティ
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
count (読み取り専用) |
The field count. |
Integer |
方法
addField(field_name, new_field_name, visible, split_rule)
Add a field info entry
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
field_name |
The field name from the input feature class or table. |
String |
|
new_field_name |
The field name for the new layer or table view. |
String |
|
visible |
Specifies whether the field will be visible or hidden.
|
String |
|
split_rule |
Specifies the behavior of an attribute's values when a feature is split.
|
String |
exportToString()
Exports the object to its string representation.
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
The string representation of the object. |
findFieldByName(field_name)
Finds the field index by field name.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
field_name |
The field name that will be used to find its index position. |
String |
戻り値
| データ タイプ | 説明 |
|---|---|
|
Integer |
The index position. |
findFieldByNewName(field_name)
Finds the field index by the new field name.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
field_name |
The new field name that will be used to find its index position. |
String |
戻り値
| データ タイプ | 説明 |
|---|---|
|
Integer |
The index position. |
getFieldName(index)
Gets the field name from the table by index position.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
Integer |
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
The field name. |
getNewName(index)
Returns the new field name from the table by index position.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
Integer |
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
The new field name. |
getSplitRule(index)
Gets the split rule from the table by index position.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
String |
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
The split rule.
|
getVisible(index)
Returns the visible flag from the table by index position.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
String |
戻り値
| データ タイプ | 説明 |
|---|---|
|
String |
The visible flag.
|
loadFromString(string)
Defines a FieldInfo object from a formatted string.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
string |
The string representation of the object. In addition to Each field is defined by four space-delimited values. Fields are separated by a semicolon.
|
String |
removeField(index)
Removes a FieldInfo entry from a table.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position of the |
Integer |
setFieldName(index, field_name)
Sets the field name in the table.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
Integer |
|
field_name |
The field name that will be set in the table. |
String |
setNewName(index, new_field_name)
Sets a new field name in the table.
注意:
While the setNewName method updates a field name in the object, the name change will not be applied when the FieldInfo object is used as input to a geoprocessing tool.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
None |
|
new_field_name |
The new field name that will be set in the table. |
String |
setSplitRule(index, rule)
Sets the split rule in the table.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
Integer |
|
rule |
Specifies the split rule that will be set in the table.
|
String |
setVisible(index, visible)
Sets the visible policy of a field in the table.
| 名前 | 説明 | データ タイプ |
|---|---|---|
|
index |
The index position. |
Integer |
|
visible |
Specifies the visible policy that will be set in the table.
|
String |
コードのサンプル
Display FieldInfo object properties for a feature layer.
import arcpy
feature_class = "c:/Data/wells.shp"
layer = "temp_layer"
arcpy.management.MakeFeatureLayer(feature_class, layer)
# Create a describe object
desc = arcpy.Describe(layer)
# Access Describe's fieldInfo property
field_info = desc.fieldInfo
# Use the count property to iterate through all the fields
for index in range(0, field_info.count):
# Print fieldinfo properties
print(f"Field Name: {field_info.getFieldName(index)}")
print(f"\tSplit Rule: {field_info.getSplitRule(index)}")
print(f"\tVisible: {field_info.getVisible(index)}")