FieldInfo

Краткая информация

Предоставляет методы и свойства информации о полях для видов слоев и таблиц.

Обсуждение

Объект FieldInfo не поддерживает переименование полей, когда объект используется в качестве входных данных для инструмента геообработки.

Синтаксис

 FieldInfo  ()

Свойства

СвойствоОписаниеТип данных
count
(только чтение)

Число полей.

Integer

Обзор метода

МетодОписание
addField (field_name, new_field_name, visible, split_rule)

Добавить запись информации поля

exportToString ()

Экспортирует объект в его строковое представление.

findFieldByName (field_name)

Находит поле индексов по имени поля.

findFieldByNewName (field_name)

Находит поле индексов по новому имени поля.

getFieldName (index)

Получает имя поля из таблицы по позиции индекса.

getNewName (index)

Возвращает новое имя поля из таблицы по позиции индекса.

getSplitRule (index)

Получает правило разбиения из таблицы по позиции индекса.

getVisible (index)

Возвращает статус видимости из таблицы по позиции индекса.

loadFromString (string)

Определяет объект FieldInfo из отформатированной строки.

removeField (index)

Удаляет запись FieldInfo из таблицы.

setFieldName (index, field_name)

Задает имя поля в таблице.

setNewName (index, new_field_name)

Задать новое имя поля в таблице.

Примечание:

Хотя метод setNewName обновляет имя поля в объекте, изменение имени не будет применено, когда объект FieldInfo используется в качестве входных данных для инструмента геообработки.

setSplitRule (index, rule)

Задает правило разбиения в таблице.

setVisible (index, visible)

Задает правила видимости поля в таблице.

Методы

addField (field_name, new_field_name, visible, split_rule)
ПараметрОписаниеТип данных
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.

  • VISIBLEThe field will be visible.
  • HIDDENThe field will be hidden.
String
split_rule

Specifies the behavior of an attribute's values when a feature is split.

  • NONEThe attributes of the two resulting features will take on a copy of the original value.
  • RATIOThe attributes of resulting features will be a ratio of the original feature's value. The ratio is based on the division of the original geometry. If the geometry is divided equally, each new feature's attribute will get one-half of the value of the original object's attribute.
String
exportToString ()
Возвращаемое значение
Тип данныхОписание
String

Строковое представление объекта.

findFieldByName (field_name)
ПараметрОписаниеТип данных
field_name

The field name that will be used to find its index position.

String
Возвращаемое значение
Тип данныхОписание
Integer

Положение индекса.

findFieldByNewName (field_name)
ПараметрОписаниеТип данных
field_name

The new field name that will be used to find its index position.

String
Возвращаемое значение
Тип данныхОписание
Integer

Значение индекса.

getFieldName (index)
ПараметрОписаниеТип данных
index

The index position.

Integer
Возвращаемое значение
Тип данныхОписание
String

Имя поля.

getNewName (index)
ПараметрОписаниеТип данных
index

The index position.

Integer
Возвращаемое значение
Тип данныхОписание
String

Новое имя поля.

getSplitRule (index)
ПараметрОписаниеТип данных
index

The index position.

String
Возвращаемое значение
Тип данныхОписание
String

Правило разбиения.

  • NONEThe attributes of the two resulting features will take on a copy of the original value.
  • RATIOThe attributes of resulting features will be a ratio of the original feature's value. The ratio is based on the division of the original geometry. If the geometry is divided equally, each new feature's attribute will get one-half of the value of the original object's attribute.
getVisible (index)
ПараметрОписаниеТип данных
index

The index position.

String
Возвращаемое значение
Тип данныхОписание
String

Статус видимости.

  • VISIBLEThe field will be visible.
  • HIDDENThe field will be hidden.
loadFromString (string)
ПараметрОписаниеТип данных
string

The string representation of the object.

In addition to FieldInfo methods and properties, you can also construct a FieldInfo object from a formatted string.

Each field is defined by four space-delimited values. Fields are separated by a semicolon.

  • The name of the input field.
  • The name of the output field (not currently supported).
  • Sets whether the field is visible or hidden.
    • VISIBLE—The field is visible.
    • HIDDEN—The field is hidden.
  • Sets the behavior of an attribute's values when a feature is split.
    • NONE—The attributes of the two resulting features take on a copy of the original value.
    • RATIO—The attributes of resulting features are a ratio of the original feature's value. The ratio is based on the division of the original geometry. If the geometry is divided equally, each new feature's attribute gets one-half of the value of the original object's attribute.
import arcpy
field_info_str = "fieldA fieldA VISIBLE NONE;fieldB fieldB HIDDEN RATIO"
field_info = arcpy.FieldInfo()
field_info.loadFromString(field_info_str)
String
removeField (index)
ПараметрОписаниеТип данных
index

The index position of the FieldInfo object.

Integer
setFieldName (index, field_name)
ПараметрОписаниеТип данных
index

The index position.

Integer
field_name

The field name that will be set in the table.

String
setNewName (index, new_field_name)
ПараметрОписаниеТип данных
index

The index position.

None
new_field_name

The new field name that will be set in the table.

String
setSplitRule (index, rule)
ПараметрОписаниеТип данных
index

The index position.

Integer
rule

Specifies the split rule that will be set in the table.

  • NONEThe attributes of the two resulting features will take on a copy of the original value.
  • RATIOThe attributes of resulting features will be a ratio of the original feature's value. The ratio is based on the division of the original geometry. If the geometry is divided equally, each new feature's attribute will get one-half of the value of the original object's attribute.
String
setVisible (index, visible)
ПараметрОписаниеТип данных
index

The index position.

Integer
visible

Specifies the visible policy that will be set in the table.

  • VISIBLEThe field will be visible.
  • HIDDENThe field will be hidden.
String

Пример кода

Пример FieldInfo

Отобразите свойства объекта FieldInfo для векторного слоя.

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)}")

Связанные разделы