Array (arcpy)
Récapitulatif
The array object can contain any number of geoprocessing objects such as points, geometries, or spatial references.
Syntaxe
Paramètre | Explication | Type de données |
items |
Items can include a list, a Point object, or another Array object. | Object |
Propriétés
Propriété | Explication | Type de données |
count (Lecture seule) |
The element count of the array. | Integer |
Vue d'ensemble des méthodes
Méthode | Explication |
add (value) |
Adds a point or array object to the end of the array |
append (value) |
Appends an object to the array in the last position. |
clone (point_object) |
Clone the point object. |
extend (items) |
Extends the array by appending elements. |
getObject (index) |
Returns the object at the given index position in the array. |
insert (index, value) |
Adds an object to the array at the specified index. |
next () |
Returns the next object at the current index. |
remove (index) |
Removes the object at the specified index position from the array. |
removeAll () |
Removes all values and creates an empty object. |
replace (index, value) |
Replaces the object at the specified index position in the array. |
reset () |
Sets the current enumeration index (used by the next method) back to the first element. |
Méthodes
Paramètre | Explication | Type de données |
value |
Either a point or array object can be appended to the array. | Object |
Paramètre | Explication | Type de données |
value |
Either a point or array object can be appended to the array. | Object |
Paramètre | Explication | Type de données |
point_object |
A point object. | Point |
Paramètre | Explication | Type de données |
items |
Extends the array by adding strings, integers, or lists. | Object |
Paramètre | Explication | Type de données |
index |
The index position of the array. | Integer |
Type de données | Explication |
Object |
The array or point object at the index position. |
Paramètre | Explication | Type de données |
index |
The index position of the array. | Integer |
value |
Either a point or array object can be inserted into the array. | Object |
Type de données | Explication |
Object |
The next object at the current index. |
Paramètre | Explication | Type de données |
index |
The index position that will be removed. | Integer |
Paramètre | Explication | Type de données |
index |
The index position that will be replaced. | Integer |
value |
The new point or array object to be added to the array. | Object |
Exemple de code
Create a polyline feature class from scratch.
import arcpy
# A list of features and coordinate pairs
#
coordList = [[[1,2], [2,4], [3,7]],
[[6,8], [5,7], [7,2], [9,5]]]
# Create empty Point and Array objects
#
point = arcpy.Point()
array = arcpy.Array()
# A list that will hold each of the Polyline objects
#
featureList = []
for feature in coordList:
# For each coordinate pair, set the x,y properties and add to the
# Array object.
#
for coordPair in feature:
point.X = coordPair[0]
point.Y = coordPair[1]
array.add(point)
# Create a Polyline object based on the array of points
#
polyline = arcpy.Polyline(array)
# Clear the array for future use
#
array.removeAll()
# Append to the list of Polyline objects
#
featureList.append(polyline)
# Create a copy of the Polyline objects, by using featureList as input to
# the CopyFeatures tool.
#
arcpy.CopyFeatures_management(featureList, "c:/geometry/polylines.shp")