ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

专为贵组织打造的制图平台

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS Developers

用于构建位置感知应用程序的工具

ArcGIS Solutions

适用于行业的免费模板地图和应用程序

ArcGIS Marketplace

获取适用于组织的应用程序和数据

  • 文档
  • 支持
Esri
  • 登录
user
  • 我的个人资料
  • 登出

ArcMap

  • 主页
  • 入门
  • 地图
  • 分析
  • 管理数据
  • 工具
  • 扩展模块

移除连接

  • 描述
  • 使用方法
  • 语法
  • 代码示例
  • 环境
  • 许可信息

描述

从要素图层或表视图中移除连接。

使用方法

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

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

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

  • 此工具不仅可在 ArcMap 中使用,还可用于其他 ArcGIS 应用程序和脚本中的图层和表视图。创建要素图层工具可从要素类中创建图层,创建表视图工具可从输入表或要素类中创建表视图。图层或表视图可随后用作添加连接和移除连接工具的输入。

语法

arcpy.management.RemoveJoin(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

try:
    # 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)
    
except Exception as err:
    print(err.args[0])

环境

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

许可信息

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

相关主题

  • 连接工具集概述

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • Esri 博客
  • 用户大会
  • 开发者峰会
Esri
分享您的想法。
Copyright © 2021 Esri. | 隐私政策 | 法律声明