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

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

TableView

  • 摘要
  • 说明
  • 语法
  • 属性
  • 方法概述
  • 方法
  • 代码示例

摘要

用于访问基本表属性。

说明

TableView 对象对于管理地图文档 (.mxd) 中的独立表至关重要。它用于访问基本表属性(如数据源信息等)以及设置表的定义查询。除了 TableView 构造函数,ListTableViews 函数也能够引用 TableView 对象。

TableView 构造函数用于在工作空间内引用地图文档外的表。它能够使用 AddTableView 函数将外部表添加到地图文档中。此函数与 MakeTableView 相似,区别在于 MakeTableView 的结果不能永久添加到地图文档中。

ListTableViews 函数返回 TableView 对象的 Python 列表。随后,必须遍历列表中的每个项目,或指定一个索引号以引用具体的 TableView 对象。可在整个地图文档或特定数据框内搜索表。通配符还可用于限制搜索。

定义查询不适用于所有工作空间。使用不同工作空间时,应用正确的 SQL 语法非常重要。例如,文件地理数据库和 shapefile 的文件名都用双引号括起(例如,"文件名"),个人地理数据库的文件名都用方括号括起(例如,[文件名]),而 SDE 连接的文件名没有任何特殊字符(例如,文件名)。有关在地图文档或图层文件中更新工作空间和数据源的详细信息,请参阅使用 arcpy.mapping 更新和修复数据源帮助主题。

可以使用 RemoveTableView 函数从地图文档中移除表。

语法

 TableView (table_view_data_source)
参数说明数据类型
table_view_data_source

A string that includes the full workspace path, including the name of the table.

String

属性

属性说明数据类型
datasetName
(只读)

以表数据集在工作空间(非内容列表)中显示的方式返回其名称。

String
dataSource
(只读)

返回表的数据源路径。此属性包含 workspacePath 和 datasetName 的组合。

String
definitionQuery
(可读写)

用于获得或设置表的定义查询。

String
name
(可读写)

用来以表在 ArcMap 内容列表中显示的方式设置或获得表名称。可包含空格。

String
isBroken
(只读)

如果表的数据源损坏,则返回 True。

Boolean
workspacePath
(只读)

返回表的工作空间或连接文件的路径。

String

方法概述

方法说明
findAndReplaceWorkspacePath (find_workspace_path, replace_workspace_path, {validate})

使用新工作空间路径替换表的工作空间

getSelectionSet ()

以 Python 对象 ID 集的形式返回表选择。

replaceDataSource (workspace_path, workspace_type, {dataset_name}, {validate})

替换地图文档 (.mxd) 中表的数据源,同时提供切换工作空间类型的功能(例如用 SDE 工作空间替换文件地理数据库工作空间)。

setSelectionSet (method, oidList)

使用 Python 对象 ID 集设置表选择。

方法

findAndReplaceWorkspacePath (find_workspace_path, replace_workspace_path, {validate})
参数说明数据类型
find_workspace_path

A string that represents the workspace path or connection file you want to find. If an empty string is passed, then all workspace paths will be replaced with the replace_workspace_path parameter depending on the value of the validate parameter.

String
replace_workspace_path

A string that represents the workspace path or connection file you want to use to replace.

String
validate

If set to True, the workspace will only be updated if the replace_workspace_path value is a valid workspace. If it is not valid, the workspace will not be replaced. If set to False, the method will set the workspace to match the replace_workspace_path, regardless of a valid match. In this case, if a match does not exist, then the table's data source would be broken.

(默认值为 True)

Boolean

有关详细说明、参数信息、案例和编码示例,请参阅更新和修复数据源帮助主题。

getSelectionSet ()

返回值

数据类型说明
List

以 Python 对象 ID 集的形式返回表选择。

提供检索表当前选择的简便方式。

replaceDataSource (workspace_path, workspace_type, {dataset_name}, {validate})
参数说明数据类型
workspace_path

A string that includes the workspace path to the new data or connection file.

String
workspace_type

A string keyword that represents the workspace type of the new data.

  • ACCESS_WORKSPACE — A personal geodatabase or Access workspace
  • ARCINFO_WORKSPACE — An ArcInfo coverage workspace
  • CAD_WORKSPACE —A CAD file workspace
  • EXCEL_WORKSPACE —An Excel file workspace
  • FILEGDB_WORKSPACE —A file geodatabase workspace
  • NONE —Used to skip the parameter
  • OLEDB_WORKSPACE —An OLE database workspace
  • PCCOVERAGE_WORKSPACE —A PC ARC/INFO Coverage workspace
  • RASTER_WORKSPACE —A raster workspace
  • SDE_WORKSPACE —An SDE geodatabase workspace
  • SHAPEFILE_WORKSPACE —A shapefile workspace
  • TEXT_WORKSPACE —A text file workspace
  • TIN_WORKSPACE —A TIN workspace
  • VPF_WORKSPACE —A VPF workspace
String
dataset_name

A string that represents the name of the table the way it appears in the new workspace (not the name of the table in the table of contents). If dataset_name is not provided, the replaceDataSource method will attempt to replace the dataset by finding a table with a the same name as the layer's current dataset property.

String
validate

If set to True, a workspace will only be updated if the workspace_path value is a valid workspace. If it is not valid, the workspace will not be replaced. If set to False, the method will set the workspace to match the workspace_path, regardless of a valid match. In this case, if a match does not exist, then the data source would be broken.

(默认值为 True)

Boolean

有参数信息、案例和代码示例等详细信息,请参阅更新和修复数据源帮助主题。

setSelectionSet (method, oidList)
参数说明数据类型
method

A string that specifies which selection method to use.

  • NEW —Creates a new record selection from the oidList.
  • DIFFERENCE —Selects the records that are not in the current selection but are in the oidList.
  • INTERSECT —Selects the records that are in the current selection and the oidList.
  • SYMDIFFERENCE —Selects the records that are in the current selection or the oidList but not both.
  • UNION —Selects all the records in both the current selection and those in the oidList.

(默认值为 None)

String
oidList

A Python set of object IDs to use along with the appropriate selection method.

Integer

此方法提供管理表选择的简便方式。要清空选择,请使用包含空集的 NEW 选择方法。Python 集或列表可用于 oidList,但会针对 Table 对象使用 getSelectionSet 方法返回集。

代码示例

TableView 示例 1

以下脚本将在名为 Transportation 的数据框中查找名为 Customers 的表并设置此表的定义查询。

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
for table in arcpy.mapping.ListTableViews(mxd, "", df):
    if table.name.lower() == "trafficaccidents":
        table.definitionQuery = "\"age\" >= 18"
mxd.save()
del mxd
TableView 示例 2

以下脚本引用文件地理数据库中的表并将此表添加到引用的地图文档中。

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Transportation")[0]
accidentsTable = arcpy.mapping.TableView(r"C:\Project\Data\Transportation.gdb\Accidents")
arcpy.mapping.AddTableView(df, accidentsTable)
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd, accidentsTable

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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