ArcGIS Desktop

  • 文档
  • 支持

  • My Profile
  • 帮助
  • Sign Out
ArcGIS Desktop

ArcGIS Online

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

ArcGIS Desktop

全面的专业性 GIS

ArcGIS Enterprise

面向企业的 GIS

ArcGIS for Developers

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

ArcGIS Solutions

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

ArcGIS Marketplace

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

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

ArcMap

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

启用附件

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

摘要

启用地理数据库要素类或表的附件。创建必要的附件关系类和将在内部存储附件文件的附件表。

  • 了解有关地理数据库附件的详细信息
  • 了解有关使用“附件”地理处理工具的详细信息

用法

  • 在可以使用添加附件工具添加附件前,必须首先使用该工具启用附件。

  • 如果地理数据库要素类或表已经启用了附件,将发出警告消息,且不进行处理。

语法

EnableAttachments_management (in_dataset)
参数说明数据类型
in_dataset

将启用附件的地理数据库表或要素类。输入的表或要素类必须处于 10 或更高版本的地理数据库中。

Table View

代码示例

EnableAttachments 示例(Python 窗口)

以下代码片段说明了如何在 Python 窗口中使用 EnableAttachments 工具。

import arcpy
arcpy.EnableAttachments_management(r"C:\Data\City.gdb\Parcels")
EnableAttachments 示例(独立 Python 脚本)

以下脚本说明了如何在独立脚本中使用 EnableAttachments 工具。

"""
Example: we have a folder of digital photographs of vacant homes; the photos
are named according to the ParcelID of the house in the picture. Let's add
these photos to a parcel feature class as attachments.
"""
import csv
import arcpy
import os
import sys
input = r"C:\Data\City.gdb\Parcels"
inputField = "ParcelID"
matchTable = r"C:\Data\matchtable.csv"
matchField = "ParcelID"
pathField = "Picture" 
picFolder = r"C:\Pictures"
try:
    # create a new Match Table csv file
    writer = csv.writer(open(matchTable, "wb"), delimiter=",")
    # write a header row (the table will have two columns: ParcelID and Picture)
    writer.writerow([matchField, pathField])
    # iterate through each picture in the directory and write a row to the table
    for file in os.listdir(picFolder):
        if str(file).find(".jpg") > -1:
            writer.writerow([str(file).replace(".jpg", ""), file])
    del writer
    # the input feature class must first be GDB attachments enabled
    arcpy.EnableAttachments_management(input)
    # use the match table with the Add Attachments tool
    arcpy.AddAttachments_management(input, targetField, matchTable, matchField, pathField, picFolder)
except Exception as err:
    print(err.args[0])

环境

  • 当前工作空间

许可信息

  • ArcGIS Desktop Basic: 否
  • ArcGIS Desktop Standard: 是
  • ArcGIS Desktop Advanced: 是

相关主题

  • 附件工具集概述
  • 使用附件地理处理工具

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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