Qualified Field Names (Environment setting)

Tools that honor the Qualified Field Names environment will use this setting to distinguish between qualified or unqualified field names. Qualified field names are the names of fields in a feature class or table that have the name of the origin feature class or table appended onto the field name itself. This setting is relevant when working with joined data.

Usage notes

When field mappings are included in a tool's parameters, as they are in many tools in the Conversion toolbox, field names are automatically UNQUALIFIED, so there is no need to set this environment.

Dialog syntax

Scripting syntax

arcpy.env.qualifiedFieldNames = qualified_field_names

qualified_field_names

Explanation

True

The output field name will include the table name. This can also be set using the QUALIFIED keyword. This is the default.

False

The output field name will not include the table name. This can also be set using the UNQUALIFIED keyword.

qualifiedFieldNames syntax
# Name: addjoin.py
# Purpose: Join a table to a featureclass and have the output
#          unqualified
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env

try:
    # Set environment settings
    env.workspace = "C:/data"
    env.qualifiedFieldNames = False
    
    # Set local variables    
    inFeatures = "Habitat_Analysis.gdb/vegtype"
    layerName  = "veg_layer"
    joinTable  = "vegtable.dbf"
    joinField  = "HOLLAND95"
    expression = "vegtable.HABITAT = 1"
    outFeature = "Habitat_Analysis.gdb/vegjoin"
    
    # Create a feature layer from the vegtype featureclass
    arcpy.MakeFeatureLayer_management(inFeatures, layerName)
    
    # Join the feature layer to a table
    arcpy.AddJoin_management(layerName, joinField, joinTable, joinField)
    
    # Copy the layer to a new permanent feature class
    # Output fields are unqualified, so the field name will 
    # not contain the origin table
    arcpy.CopyFeatures_management(layerName, outFeature)
    
except Exception, e:
    # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message

Related Topics


3/13/2012