ArcGIS for Desktop

  • 文档
  • 合约
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

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

ArcGIS for Desktop

全面的专业性 GIS

ArcGIS for Server

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

帮助

  • 主页
  • 入门
  • 制图
  • 分析
  • 管理数据
  • 工具
  • 更多...

迁移关系类

  • 摘要
  • 用法
  • 语法
  • 代码实例
  • 环境
  • 许可信息

摘要

将基于 ObjectID 的关系类迁移到基于 GlobalID 的关系类。

用法

  • 此工具可将基于 ObjectID 的关系类修改为基于 GlobalID 的关系类,从而满足运行时地理数据库的要求。

  • 输入关系类中输入的源要素类或表必须具有一个靠前的 GlobalID 字段使用此工具。同时,目标类也必须具有一个 GlobalID 字段。

  • 现有输入关系类必须基于 ObjectID。可能未对数据启用存档。

  • 此工具支持将版本化和非版本化的数据作为输入。

  • 此工具不支持将要素关联的注记关系类作为输入,因为这些关系必须保持基于 ObjectID。

  • 建议将数据的备份副本用作此工具的输入。

语法

MigrateRelationshipClass_management (in_relationship_class)
参数说明数据类型
in_relationship_class

基于 ObjectID 的关系类,将被迁移至基于 GlobalID 的关系类。源要素类和目标要素类或表必须已经具有 GlobalID。

Relationship Class

代码实例

MigrateRelationshipClass 示例 1(Python 窗口)

以下 Python 窗口脚本演示了如何在即时模式下使用 MigrateRelationshipClass 工具。

arcpy.MigrateRelationshipClass_management(r'C:\Data\Relationships.gdb\OneToMany')
MigrateRelationshipClass 示例 2(独立脚本)

以下脚本演示了如何在独立脚本中使用 MigrateRelationshipClass 工具。

# Name: MigrateRelationshipClass_Example.py
# Description: Migrate an ObjectID-based relationship class to a GlobalID-based
#       relationship class. This script lists the ObjectID-based relationships classes
#       in a workspace, checks for GlobalIDs in the origin, then runs the tool

# Import system modules
import arcpy

# Set local variables
workspace = r'C:\Data\Relationships.gdb'

# List all of the relationship classes within the given workspace
rc_list = [c.name for c in arcpy.Describe(workspace).children if c.datatype == "RelationshipClass"]

# Build a list of relationship classes which have an OBJECTID based origin class key
rc_migrate = []
for rc in rc_list:
    rc_path = workspace + "\\" + rc
    rc_desc = arcpy.Describe(rc_path)
    for item in rc_desc.OriginClassKeys:
        if "OBJECTID" in item:
            rc_migrate.append(rc_path)

# Check that the origin feature classes have Global Ids
rc_final = []
for rel in rc_migrate:
    originfc = workspace + "\\" + arcpy.Describe(rel).originClassNames[0]
    if arcpy.ListFields(originfc,"","GlobalID"):
        rc_final.append(rel)
        print("Adding {0}  to the list to migrate. \n".format(rel.rsplit("\\",1)[1]))
    else:
        print("{0} must have Global Ids to migrate relationship class.\n".format(originfc.rsplit("\\",1)[1]))

# Pass the list of valid relationship classes into the Migrate Relationship tool
print("Passing valid relationship classes into the Migrate Relationship Class tool.\n")
for rel_class in rc_final:
    print("Migrating {0}... \n".format(rel_class.rsplit("\\",1)[1]))
    arcpy.MigrateRelationshipClass_management(rel_class)
    print(arcpy.GetMessages() + "\n")

环境

  • 当前工作空间

相关主题

  • 关系类工具集概述
  • 关系类属性
有关此主题的反馈?

ArcGIS for Desktop

  • 主页
  • 文档
  • 合约
  • 支持

ArcGIS 平台

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

关于 Esri

  • 关于我们
  • 招贤纳士
  • 内部人员博客
  • 用户大会
  • 开发者峰会
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | 隐私政策 | 法律声明