Attribute übertragen (Editieren)

Lizenzstufe:BasicStandardAdvanced

Zusammenfassung

Ermittelt, wo die Quellen-Linien-Features räumlich mit den Ziel-Linien-Features übereinstimmen, und überträgt angegebene Attribute von Quell-Features auf abgeglichene Ziel-Features.

Die Attributübertragung wird normalerweise verwendet, um Attribute von Features in einem Dataset zu entsprechenden Features in einem anderen Dataset zu kopieren. Beispielsweise kann sie verwendet werden, um die Namen von Straßen-Features von einem zuvor digitalisierten und verwalteten Dataset auf Features, die neu erfasst und genauer sind, in einem neuen Dataset zu übertragen. Die zwei Datasets werden gewöhnlich als Quell-Features und Ziel-Features bezeichnet. Dieses Werkzeug ermittelt einander entsprechende Quellen- und Ziellinien-Features innerhalb der angegebenen Suchentfernung und überträgt die angegebenen Attribute von Quell-Linien auf Ziellinien.

Bild

Attribute übertragen

Verwendung

Syntax

TransferAttributes_edit (source_features, target_features, transfer_fields, search_distance, {match_fields}, {out_match_table})
ParameterErläuterungDatentyp
source_features

Linien-Features, aus denen Attribute übertragen werden sollen.

Feature Layer
target_features

Linien-Features, zu denen Attribute übertragen werden sollen. Die angegebenen Übertragungsfelder werden zu den Ziel-Features hinzugefügt.

Feature Layer
transfer_fields
[field,...]

Liste der Quellenfellder, die zu Ziel-Features übertragen werden sollen. Es muss mindestens ein Feld angegeben werden.

Field
search_distance

Die für die Suche nach Übereinstimmungskandidaten verwendete Entfernung. Die Entfernung muss angegeben und größer als null sein. Sie können eine bevorzugte Einheit auswählen. Standardmäßig wird die Feature-Einheit verwendet.

Linear unit
match_fields
[[source_field, target_field],...]
(optional)

Liste der Felder aus Quellen- und Ziel-Features. Falls angegeben, wird jedes Feldpaar auf Übereinstimmungskandidaten geprüft, um die Ermittlung des richtigen Treffers zu ermöglichen.

Value Table
out_match_table
(optional)

Die Ausgabetabelle mit vollständigen Informationen zum Feature-Abgleich.

Table

Codebeispiel

TransferAttributes – Beispiel 1 (Python-Fenster)

Das folgende Skript im Python-Fenster veranschaulicht, wie die Funktion "TransferAttributes" im unmittelbaren Modus verwendet wird.

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.TransferAttributes_edit("source_Roads.shp",
                              "target_Roads.shp", "RoadName, PaveType"
                              "25 Feet")
TransferAttributes – Beispiel 2 (eigenständiges Python-Skript)

Das folgende eigenständige Skript ist ein Beispiel für die Anwendung der Funktion "TransferAttributes" in einer Scripting-Umgebung.

# Name:        TransferAttributes_example_script2.py
# 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.
# ====================================================================================

Umgebung

Verwandte Themen

Lizenzierungsinformationen

ArcGIS for Desktop Basic: Nein
ArcGIS for Desktop Standard: Nein
ArcGIS for Desktop Advanced: Ja
5/12/2014