Array
汇总
Array 对象可以包含 点 和数组,用于构造几何对象。
语法
Array({items})
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
items (可选) |
Items can include a |
Object |
属性
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
count (只读) |
数组的元素计数。 |
Integer |
方法
add(value)
将 Point 或 Array 对象添加到数组的结尾处。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
value |
Either a |
Object |
append(value)
在数组中的最后一个位置追加一个对象。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
value |
Either a |
Object |
clone(point_object)
克隆 Point 对象。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
point_object |
A |
Point |
extend(items)
通过追加元素扩展数组。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
items |
Extend the array by adding strings, integers, or lists. |
Object |
getObject(index)
返回数组中给定索引位置上的对象。
getObject 方法等同于建立对象索引;即 obj.getObject(0) 等同于 obj[0] 。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
index |
The index position of the array. |
Integer |
返回值
| 数据类型 | 说明 |
|---|---|
|
Object |
索引位置上的 |
insert(index, value)
在 Array 对象中的指定索引处添加一个对象。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
index |
The index position of the |
Integer |
|
value |
The |
Object |
next()
返回当前索引中的下一个对象。
返回值
| 数据类型 | 说明 |
|---|---|
|
Object |
当前索引中的下一个对象。 |
remove(index)
从数组中的指定索引位置移除对象。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
index |
The index position that will be removed. |
Integer |
removeAll()
移除所有值并创建一个空对象。
replace(index, value)
替换 Array 对象中指定索引位置上的对象。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
index |
The index position that will be replaced. |
Integer |
|
value |
The new |
Object |
reset()
将当前枚举索引(由 next 方法使用)设置回第一个元素。
代码示例
从头开始创建折线要素类。
import arcpy
# A list of features and coordinate pairs
feature_info = [[[425585.75, 3769682.59],
[426151.56, 3767215.02],
[424941.35, 3764983.2]],
[[416248.53, 3770551.91],
[416229.21, 3769315.87],
[417851.51, 3769270.81],
[417870.83, 3770493.97]]]
spatial_ref = arcpy.SpatialReference(26911) # NAD 1983 UTM Zone 11N
# A list that will hold each of the Polyline objects
features = []
for feature in feature_info:
# Create a Polyline object based on the array of points
# Append to the list of Polyline objects
features.append(
arcpy.Polyline(
arcpy.Array([arcpy.Point(*coords) for coords in feature]),
spatial_ref))
# Persist a copy of the Polyline objects using CopyFeatures
arcpy.management.CopyFeatures(features, "c:/geometry/polylines.shp")