Transfer Attributes (Editing)

License Level:BasicStandardAdvanced


Finds where the source line features spatially match the target line features and transfers specified attributes from source features to matched target features.

Attribute transfer is typically used to copy attributes from features in one dataset to corresponding features in another dataset. For example, it can be used to transfer the names of road features from a previously digitized and maintained dataset to features in a new dataset that are newly collected and more accurate. The two datasets are usually referred to as source features and target features. This tool finds corresponding source and target line features within the specified search distance and transfers the specified attributes from source lines to target lines.


Transfer Attributes



TransferAttributes_edit (source_features, target_features, transfer_fields, search_distance, {match_fields}, {out_match_table})
ParameterExplanationData Type

Line features from which to transfer attributes.

Feature Layer

Line features to which to transfer attributes. The specified transfer fields are added to the target features.

Feature Layer

List of source fields to be transferred to target features. At least one field must be specified.


The distance used to search for match candidates. A distance must be specified and it must be greater than zero. You can choose a preferred unit; the default is the feature unit.

Linear unit
[[source_field, target_field],...]

Lists of fields from source and target features. If specified, each pair of fields are checked for match candidates to help determine the right match.

Value Table

The output table containing complete feature matching information.


Code Sample

TransferAttributes example 1 (Python window)

The following Python window script demonstrates how to use the TransferAttributes function in immediate mode.

import arcpy
arcpy.env.workspace = "C:/data"
                              "target_Roads.shp", "RoadName, PaveType"
                              "25 Feet")
TransferAttributes example 2 (stand-alone Python script)

The following stand-alone script is an example of how to apply the TransferAttributes function in a scripting environment.

# Name:
# Description: Performs attribute transfer from newly updated roads (source) to existing
#              base roads (target). Where the source and target features are matched in
#              many-to-one or many-to-many (m:n) relationships, attributes are transferred 
#              from only one of the m source features to the n target features. This script
#              includes a post-process that flags resulting target features with the m:n
#              match relationships. You can inspect the flagged features and retrieve the
#              attributes from the desired source features if necessary.
# Author:      Esri
# -----------------------------------------------------------------------

# Import system modules
import arcpy
from arcpy import env

# Set environment settings
env.overwriteOutput = True
env.workspace = r"D:\conflationTools\ScriptExamples\data.gdb"

# Set local variables
sourceFeatures = "updateRoads"
targetFeatures = "baseRoads"
transfer_fields = "RD_NAME; RD_ID"

search_distance = "300 Feet"
match_fields = "RD_NAME FULLNAME"

outMatchTable = "ta_mtbl"

# Make a copy of the targetFeatures for attribute transfer
targetCopy = targetFeatures + "_Copy"
arcpy.CopyFeatures_management(targetFeatures, targetCopy)

# Performs attribute transfer
arcpy.TransferAttributes_edit(sourceFeatures, targetCopy, transfer_fields, search_distance, match_fields, outMatchTable)

# ====================================================================================
# Note 1:  The result of TransferAttributes may contain errors; see tool reference.
#          Additional analysis steps may be necessary to check the results; these steps
#          are not included in this script.
#          The following process identifies m:n matches between source and target features 
#          and flag features in targetCopy for inspection.
# ====================================================================================

# Add a field srcM_inMN to the match table to store the m count of source features in m:n relationship
field_srcM_inMN = "srcM_inMN"
arcpy.AddField_management(outMatchTable, field_srcM_inMN)

codeblock = """
def getM(fld):
    x = fld.split(\":\")[0]
    if x.isnumeric():
        if int(x) > 0:
            return int(x)
    return -1

# Calculate values for srcM_inMN
arcpy.CalculateField_management(outMatchTable, field_srcM_inMN, "getM(!FM_MN!)", "PYTHON_9.3", codeblock)

# Make a table view of the match table, selecting srcM_inMN values greater than 1 
# (excluding 1:n relationships which don't need to be inspected)
arcpy.MakeTableView_management(outMatchTable, "mtable_view", field_srcM_inMN + "> 1")

# For the selected records, transfer srcM_inMN and SRC_FID fields and values to the targetCopy
arcpy.JoinField_management(targetCopy, "OBJECTID", "mtable_view", "TGT_FID", field_srcM_inMN + "; SRC_FID")

# ====================================================================================
# Note 2:  Now the fields srcM_inMN and SRC_FID are in the copy of the target features.
#          The srcM_inMN values are the counts of matched source features; the SRC_FID
#          values indicate the source feature IDs from which the transferred attributes
#          come from.
#          At this point you can interactively review the transferred attributes for the
#          flagged features. If you want to replace any of them by those from a different
#          source feature, you would need to make the edits as needed.
# ====================================================================================


Related Topics

Licensing Information

ArcGIS for Desktop Basic: No
ArcGIS for Desktop Standard: No
ArcGIS for Desktop Advanced: Yes