FieldInfo

サマリー

Provides field info methods and properties for layer and table views.

構文

 FieldInfo  ()

プロパティ

プロパティ説明データ タイプ
count
(読み取り専用)

The field count.

Integer

方法の概要

方法説明
addField (field_name, new_field_name, visible, split_rule)

Adds a field info entry

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)

Returns the new field name from the table by index position.

getSplitRule (index)

Gets the split rule from the table by index position.

getVisible (index)

Returns the visible flag from the table by index position.

loadFromString (string)

Restore or update the spatial reference object using a WKT string. The exportToString method can be used to export a WKT string representation of the spatial reference.

  • Using a WKT string with a horizontal coordinate system.
    # The following string is the WKT for the 
    # Geographic Coordinate system "WGS 1984" (factory code=4326)
    wkt = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],\
                  PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]];\
                  -400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;\
                  0.001;0.001;IsHighPrecision'
    
    sr = arcpy.SpatialReference()
    sr.loadFromString(wkt)
  • Using a WKT string with a horizontal and vertical coordinate system. Note that the vertical coordinate system is defined in the VERTCS section of the WKT.
    # The following string is the WKT for the 
    # Geographic Coordinate system "WGS 1984" (factory code=4326), 
    # with a vertical coordinate system "WGS 1984" (factory code=115700)
    
    wkt = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],\
                  PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],\
                  VERTCS["WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],\
                  PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]];\
                  -400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;\
                  0.001;0.001;IsHighPrecision'
    
    sr = arcpy.SpatialReference()
    sr.loadFromString(wkt)

removeField (index)

Removes a FieldInfo 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.

方法

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

Sets the field name for the new layer or table view.

String
visible

Sets whether the field is visible or hidden.

  • VISIBLEField is visible.
  • HIDDENField is hidden.
String
split_rule

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

  • NONEThe attributes of the two resulting features take on a copy of the original value.
  • RATIOThe 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.
String
exportToString ()
戻り値
データ タイプ説明
String

The WKT string representation of the object.

findFieldByName (field_name)
パラメーター説明データ タイプ
field_name

The field name used to find its index position

String
戻り値
データ タイプ説明
Integer

The index position

findFieldByNewName (field_name)
パラメーター説明データ タイプ
field_name

The new field name used to find its index position.

String
戻り値
データ タイプ説明
Integer

The index position.

getFieldName (index)
パラメーター説明データ タイプ
index

The index position.

Integer
戻り値
データ タイプ説明
String

The field name.

getNewName (index)
パラメーター説明データ タイプ
index

The index position.

Integer
戻り値
データ タイプ説明
String

The new field name.

getSplitRule (index)
パラメーター説明データ タイプ
index

The index position.

String
戻り値
データ タイプ説明
String

The split rule.

  • NONEThe attributes of the two resulting features take on a copy of the original value.
  • RATIOThe 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.
getVisible (index)
パラメーター説明データ タイプ
index

The index position.

String
戻り値
データ タイプ説明
String

The visible flag.

  • VISIBLEField is visible.
  • HIDDENField is hidden.
loadFromString (string)
パラメーター説明データ タイプ
string

The WKT string representation of the object.

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 to set into the table.

String
setNewName (index, new_field_name)
パラメーター説明データ タイプ
index

The index position.

None
new_field_name

The new field name to set into the table.

String
setSplitRule (index, rule)
パラメーター説明データ タイプ
index

The index position.

Integer
rule

The split rule to set into the table.

  • NONEThe attributes of the two resulting features take on a copy of the original value.
  • RATIOThe 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.
String
setVisible (index, visible)
パラメーター説明データ タイプ
index

The index position.

Integer
visible

The visible policy to set into the table.

  • VISIBLEField is visible.
  • HIDDENField is hidden.
String

コードのサンプル

FieldInfo example

Display FieldInfo properties for a feature layer.

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 range(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)))

関連トピック