移除连接 (数据管理)

摘要

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

使用情况

  • 连接参数是连接到输入图层或表视图的表的名称。

    • 如果连接表是名为 MyTable.dbf 的 dBASE 文件,则连接名称将是“MyTable”;因此,要移除该连接,请指定“MyTable”。
    • 如果连接表是名为 MyTable2 的 INFO 或地理数据库表,则“连接名称”将是“MyTable2”;因此,要移除该连接,请指定“MyTable2”。
    • 连接名称不会反映表视图本身的名称,而是反映表视图的源。因此,如果表视图名为 TableView1 并指向 mytable.dbf,则连接的名称将是“mytable”。

  • 如果图层连接到两个表并且移除了第一个连接,则两个连接都将被移除。例如,将 Layer1 连接到 TableA。然后将 Layer1 连接到 TableB。如果移除了 TableA 的连接,则将一并移除 TableB 的连接。

  • 在“模型构建器”中,可使用创建要素图层工具通过要素类创建图层,创建表视图工具可通过输入表或要素类创建表视图。这些图层或表视图可随后用作添加连接移除连接工具的输入。

参数

标注说明数据类型
图层名称或表视图

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

Mosaic Layer; Raster Layer; Table View
连接
(可选)

要移除的连接。

String

派生输出

标注说明数据类型
连接已移除的图层

已更新的输入数据集。

表视图;栅格图层;镶嵌图层

arcpy.management.RemoveJoin(in_layer_or_view, {join_name})
名称说明数据类型
in_layer_or_view

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

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

要移除的连接。

String

派生输出

名称说明数据类型
out_layer_or_view

已更新的输入数据集。

表视图;栅格图层;镶嵌图层

代码示例

RemoveJoin 示例 1(Python 窗口)

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

import arcpy
arcpy.RemoveJoin_management("veglayer", "vegtable")
RemoveJoin 示例 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
# set the environments
arcpy.env.workspace = "C:/data"
arcpy.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)

环境

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

许可信息

  • Basic: 是
  • Standard: 是
  • Advanced: 是

相关主题