Vector Methods

GISDK vectors now have several methods which allow transformations and other operations.

Changes

New in Version 2022.

find(var value)

Returns the search value if found in the vector, or null if value is not found. The method does not raise an error, even when the input does not match the vector type. For example:

arr = {10, 20, 30, 40}
 v = a2v(arr)
 test_1 = v.find("hi") // test_1 = null
 test_2 = v.find(100) // test_2 = null
test_3 = v.find(10) // test_3 = 10

position(var search_value)

Equivalent to the 'find' method but returns the index in the vector of the first element that matches search_value, or 0 search_value is not found. The method does not raise an error, even when the input does not match the vector type.

arr = {10, 20, 30, 40}
v = a2v(arr)
pos_1 = v.position(20) // pos_1 = 2
pos_2 = v.position("hi") // pos_2 = 0

contains (var search_value)

Returns true if the vector contains the search_value, false otherwise. The method does not raise an error, even when the input does not match the vector type.

arr = {10, 20, 30, 40}
v = a2v(arr)
ret_1 = v.contains(20) // ret = 1
ret_2 = v.contains("hi") // ret = null
ret_3 = v.contains(7) // ret = null

sum ()

Computes the sum of a vector of numbers.

arr = {10, 20, 30, 40}
v = a2v(arr)
s = v.sum() // s = 100

count(array options)

Returns the vector's length. The "Ignore Missing" option can be used to count only non-null values

arr = {10, 20, 30, null, 40, null}
v = a2v(arr)
opt = {"ignore Missing": True}
l = v.Count(opt) // l = 4

mean()

Returns the mean of a vector of numbers.

arr = {10, 20, 30, 40}
v = a2v(arr)
m = v.Mean() // m = 25

percentile(array options)

Returns the n-th percentile of a vector of numbers using the Percentile option value as n. if the Percentile option is null the 50th percentile is returned.

arr = {10, 20, 30, 40}
v = a2v(arr)
p= v.Percentile( {Percentile: 20}) // p = 16

maxindex()

Returns the index of the first occurrence of the maximum value in a vector.

arr = {10, 20, 30, 40, 40 , 40}
v = a2v(arr)
mi = v.MinIndex() // mi = 4

minindex()

Returns the index of the first occurrence of the minimum value in a vector.

arr = {10, 20, 30, 40, 1 , 1}
v = a2v(arr)
mi = v.MinIndex() // mi = 1

Vector methods can be applied to function results but not to parenthesized expressions. For example:

This a valid use of the sum method.

Pop = GetDataVector(, "Population", ).Sum()