ArrayToVector(), A2V()
Summary
Copies an array to a vector.
Changes
Added to Version 6.0/2012.
Syntax
vec = ArrayToVector(array arr [, array options])
| Argument | Contents |
|---|---|
| arr | The array to convert to a vector |
| Options | Type | Contents |
|---|---|---|
| Row Based | String | "True" (the default) means v.rowbased will be "True"; "False" means v.columnbased will be "True" |
| Type | String | The type of number ("Double", "Float", "Long", or "Short"), or the type "String" |
Returns
A vector.
Notes
The options array is an optional argument.
If no Type is provided, the array elements are scanned and a reasonable type is chosen. Double will be chosen rather than Float to prevent loss of precision.
If an array element cannot be converted to the Type of the vector, it is set to null.
Can also be called as A2V().
For more information on vectors, see Vectors.
Examples
arr = {1, 3, 5.6, 7, 9}
vec = ArrayToVector(arr)
ShowArray({vec}) // vec = 1.0, 3.0, 5.6, 7.0, 9.0 as doubles
arr = {1, 3, 5.6, "7", 9}
vec = ArrayToVector(arr)
ShowArray({vec}) // vec = "1", "3", "5.6", "7", "9"
arr = {1.2, 3.4, 5.6, "7", 9}
vec = ArrayToVector(arr, {{"Type","Float"}})
ShowArray({vec}) // vec = 1.2, 3.4, 5.6, null, 9.0
See Also
| GISDK Function | Summary |
|---|---|
| CopyVector() | Copies a vector to a new vector |
| CumulativeVector() | Constructs a cumulative vector in a new vector |
| ConcatenateVectors() | Concatenates vectors into one, combined long vector |
| GetDataVector() | Creates a vector from a field in a view|set |
| GetDataVectors() | Creates vectors from fields in a view|set |
| SetDataVector() | Fills values into a field in a view|set from a vector |
| SetDataVectors() | Fills values into fields in a view|set from vectors |
| SortVector() | Sorts the elements of a vector in ascending order |
| SortVectors() | Sorts an array of vectors in ascending order, based on the first vector |
| TransposeArray() | Transposes an array of arrays, where element b[i][j] = a[j][i] |
| Vector() | Creates a vector |
| VectorStatistic() | Computes a given statistic for the vector |
| VectorToArray() | Copies a vector to an array |