Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.



The VALUE_LOCATE function finds the intervals within a given monotonic vector that brackets a given set of one or more search values. This function is useful for interpolation and table-lookup, and is an adaptation of the locate() routine in Numerical Recipes. VALUE_LOCATE uses the bisection method to locate the interval.


; Define a vector of values.
vec = [2,5,8,10]
; Compute location of other values within
; that vector.
loc = VALUE_LOCATE(vec, [0,3,5,6,12])
PRINT, loc

IDL prints:

-1   0   1   1   3


Result = VALUE_LOCATE ( Vector, Value [, /L64 ] )

Return Value

Each return value, Result [i], is an index, j, into Vector, corresponding to the interval into which the given Value [i] falls. The returned values are in the range –1 ≤ jN–1, where N is the number of elements in the input vector.

If Vector is monotonically increasing, the result j is:

if j = –1               Value [i] < Vector [0]

if 0 ≤j < N–1        Vector [j] ≤Value [i] < Vector [j+1]

if j = N–1             Vector [N–1] ≤Value [i]

If Vector is monotonically decreasing

if j = –1               Vector [0] ≤Value [i]

if 0 ≤j < N–1        Vector [j+1] ≤Value [i] < Vector [j]

if j = N–1             Value [i] < Vector [N–1]



A vector of monotonically increasing or decreasing values. Vector may be of type string, or any numeric type except complex, and may not contain the value NaN (not-a-number).


The value for which the location of the intervals is to be computed. Value may be either a scalar or an array. The return value will contain the same number of elements as this parameter.



By default, the result of VALUE_LOCATE is 32-bit integer when possible, and 64-bit integer if the number of elements being processed requires it. Set L64 to force 64-bit integers to be returned in all cases.

Note: Only 64-bit versions of IDL are capable of creating variables requiring a 64-bit result. Check the value of !VERSION.MEMORY_BITS to see if your IDL is 64-bit or not.

Version History



8.2.2 Allow Vector to be a 1-element array or scalar

© 2017 Exelis Visual Information Solutions, Inc. |  Legal
My Account    |    Buy    |    Contact Us