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

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

ValueTable

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

摘要

值表是一种灵活的对象,可用作多值参数的输入。它仅在创建此表的地理处理对象的生存时间内存在。

说明

setRow 的值参数以空格分隔。含有空格的值参数中使用的所有值均必须用引号括起。在下例中,向包含两列的值表中分别添加了一个要素类和一个索引值:

value_table.setRow(0, "'c:/temp/land use.shp' 2")

语法

 ValueTable  ({columns})
参数说明数据类型
columns

The number of columns.

(默认值为 1)

Integer

属性

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

The number of columns.

Integer
rowCount
(只读)

The number of rows.

Integer

方法概述

方法说明
addRow (value)

向值表中添加一行。

addRow 的值参数是以空格分隔的。含有空格的值参数中使用的所有值均必须用引号括起。在下例中,向包含两列的值表中分别添加了一个要素类和一个索引值:

vtab.addRow("'c:/temp/land use.shp' 2")

exportToString ()

将对象导出至其字符串表示。

getRow (row)

获取值表中的某一行。

getTrueValue (row, column)

获取给定的列和行中的值。

getValue (row, column)

获取给定的列和行中的值。

loadFromString (string)

使用对象的字符串表示来恢复对象。可以使用 exportToString 方法创建字符串表示。

removeRow (row)

从值表中删除一行。

setColumns (number_of_columns)

设置值表的列数。

setRow (row, value)

更新值表中的给定行。

setRow 的值参数以空格分隔。含有空格的值参数中使用的所有值均必须用引号括起。在下例中,向包含两列的值表中分别添加了一个要素类和一个索引值:

vtab.setRow(0, "'c:/temp/land use.shp' 2")
setValue (row, column, value)

更新给定行或列的值。

方法

addRow (value)
参数说明数据类型
value

要添加的行。

Object
exportToString ()

返回值

数据类型说明
String

对象的字符串表示。

getRow (row)
参数说明数据类型
row

行索引位置。

Integer

返回值

数据类型说明
String

值表中的某一行。

getTrueValue (row, column)
参数说明数据类型
row

行索引位置。

Integer
column

列索引位置。

Integer

返回值

数据类型说明
String

给定的列和行中的值。

getValue (row, column)
参数说明数据类型
row

行索引位置。

Integer
column

列索引位置。

Integer

返回值

数据类型说明
String

给定的列和行中的值。

loadFromString (string)
参数说明数据类型
string

对象的字符串表示。

String
removeRow (row)
参数说明数据类型
row

待移除行的索引位置。

Integer
setColumns (number_of_columns)
参数说明数据类型
number_of_columns

值表的列数。

Integer
setRow (row, value)
参数说明数据类型
row

待更新行的索引位置。

Integer
value

用于更新给定行的值。

Object
setValue (row, column, value)
参数说明数据类型
row

行索引。

Integer
column

列索引。

Integer
value

用于更新给定行和列的值。

Object

代码示例

ValueTable 示例

使用 ValueTable 保存联合工具的要素类名称和等级。

import arcpy
# Set the workspace. List all of the feature classes in the dataset
arcpy.env.workspace = "c:/data/landbase.gdb/Wetlands"
feature_classes = arcpy.ListFeatureClasses()
# Create the value table for the Analysis Union tool with 2 columns
value_table = arcpy.ValueTable(2)
# Iterate through the list of feature classes
for fc in feature_classes:
    # Update the value table with a rank of 2 for each record, except
    #   for BigBog
    if fc.lower() != "bigbog":
        value_table.addRow(fc + " 2")
    else:
        value_table.addRow(fc + " 1")
# Union the wetlands feature classes with the land use feature class to create
#   a single feature class with all of the wetlands and land use data
value_table.addRow("c:/data/landbase.gdb/land_use 2")
arcpy.Union_analysis(value_table, "c:/data/landbase.gdb/wetlands_use")
ValueTable 示例 2

如果已将多值字符串作为参数传递到脚本,则可用其填充值表,以使提取各记录更为简便。以下示例将对此操作方法进行说明:

import os
import arcpy
# Set the output workspace
arcpy.env.workspace = arcpy.GetParameterAsText(1)
# Create a value table with 2 columns
value_table = arcpy.ValueTable(2)
# Set the values of the table with the contents of the first argument
value_table.loadFromString(arcpy.GetParameterAsText(0))
# Loop through the list of inputs
for i in range(0, value_table.rowCount):
    # Validate the output name for the new workspace
    name = value_table.getRow(i)
    out_name = arcpy.ValidateTableName(os.path.basename(name))
    # Copy the features to the new workspace
    arcpy.CopyFeatures_management(name, out_name)

相关主题

  • 使用多值输入

ArcGIS Desktop

  • 主页
  • 文档
  • 支持

ArcGIS 平台

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

关于 Esri

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