移除连接 (Data Management)

许可等级:BasicStandardAdvanced

摘要

要素图层表视图中移除连接

用法

语法

RemoveJoin_management (in_layer_or_view, {join_name})
参数说明数据类型
in_layer_or_view

要移除连接的图层或表视图。

Mosaic Layer; Raster Catalog Layer; Raster Layer; Table View
join_name
(可选)

要移除的连接。

String

代码实例

移除连接示例(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 ArcMap 中的移除连接 (RemoveJoin) 工具处理 TOC 指定的 veglayer 中的要素图层。

arcpy.RemoveJoin_management("veglayer", "vegtable")
移除连接示例 2(独立脚本)

此独立脚本中 RemoveJoin 函数是工作流的一部分,该工作流将向表中添加字段并基于连接表中字段的值计算该字段值。

# AddFieldFromJoin.py
# Description: Adds a field to a table, and calculates its values based
#              on the values in a field from a joined table

# Import system modules
import arcpy
from arcpy import env

try:
    # set the environments
    env.workspace = "C:/data"
    env.qualifiedFieldNames = "UNQUALIFIED"
    
    # Define script parameters    
    inFeatures = "Habitat_Analysis.gdb/vegtype"
    layerName = "veg_layer"
    newField = "description"
    joinTable = "vegtable.dbf"
    joinField = "HOLLAND95"
    calcExpression = "!vegtable.VEG_TYPE!"
    outFeature = "Habitat_Analysis.gdb/vegjoin335"
    
    # Add the new field
    arcpy.AddField_management (inFeatures, newField, "TEXT")
    
    # 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)
    
    # Populate the newly created field with values from the joined table
    arcpy.CalculateField_management (layerName, newField, calcExpression, "PYTHON")
    
    # Remove the join
    arcpy.RemoveJoin_management (layerName, "vegtable")
    
    # Copy the layer to a new permanent feature class
    arcpy.CopyFeatures_management (layerName, outFeature)
    
except Exception, e:
    
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message

环境

此工具不使用任何地理处理环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014