ExtendTable (arcpy.da)
摘要
基于公共属性字段将 NumPy 结构化数组的内容连接到表。输入表将被更新,从而包含连接表中的字段。
讨论
in_array 中的记录与 in_table 中的记录相匹配。table_match_field 与 array_match_table 的值相等时进行匹配。该连接是永久性的。
NumPy 是 Python 中用于进行科学计算的基础包,其包括支持功能强大的 N 维数组对象。有关详细信息,请参阅在 ArcGIS 中使用 NumPy。
语法
参数 | 说明 | 数据类型 |
in_table |
The target table to which fields from a NumPy array will be appended. | String |
table_match_field | Field name from in_table to use as a match to the array. | String |
in_array | NumPy structured array to be appended to in_table. Matching in_array field values must be unique. | NumPyArray |
array_match_field | Field name from in_array to use to match. | String |
append_only | Controls how fields are added or updated in the existing table. If True, fields will be appended to the existing table only. If any of NumPy field names exist already in the in_table, ExtendTable will fail. If False, existing fields will be updated if they share a common field name with fields in the NumPy array. Any matching fields must have a compatible field type. For example, a NumPy string field cannot be appended into a numeric field. (默认值为 True) | Boolean |
代码实例
使用 ExtendTable 将 NumPy 数组连接至现有表。
import arcpy
import numpy
# numpy array
#
array = numpy.array([(1, 'a', 1111.0), (2, 'b', 2222.22)],
numpy.dtype([('idfield',numpy.int32),
('textfield', '|S256'),
('doublefield','<f8')]))
# Append the array to an existing table
#
arcpy.da.ExtendTable("c:/data/base.gdb/current_table",
"tableid",
array,
"idfield")