移除连接 (Data Management)
摘要
从要素图层或表视图中移除连接。
用法
- 
连接参数是连接到输入图层或表视图的表的名称。 - 如果连接表是名为 MyTable.dbf 的 dBASE 文件,则连接名称将是“MyTable”;因此,要移除该连接,请指定“MyTable”。
- 如果连接表是名为 MyTable2 的 INFO 或地理数据库表,则“连接名称”将是“MyTable2”;因此,要移除该连接,请指定“MyTable2”。
- 连接名称不会反映表视图本身的名称,而是反映表视图的源。因此,如果表视图名为 TableView1 并指向 mytable.dbf,则连接的名称将是“mytable”。
 
- 
如果图层连接到两个表并且移除了第一个连接,则两个连接都将被移除。例如,将 Layer1 连接到 TableA。然后将 Layer1 连接到 TableB。如果移除了 TableA 的连接,则将一并移除 TableB 的连接。 
- 
此工具不仅可在 ArcMap 中使用,还可用于其他 ArcGIS 应用程序和脚本中的图层和表视图。创建要素图层工具可从要素类中创建图层,创建表视图工具可从输入表或要素类中创建表视图。图层或表视图可随后用作添加连接和移除连接工具的输入。 
语法
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