pyinterp.RTree.value#
- RTree.value(coordinates: numpy.ndarray, radius: float | None = None, k: int = 4, within: bool = True, num_threads: int = 0) tuple[numpy.ndarray, numpy.ndarray] [source]#
Get the coordinates and values for the K-nearest neighbors of a given point.
- Parameters:
coordinates – a matrix
(n, ndims)
wheren
is the number of observations andndims
is the number of coordinates in order: longitude and latitude in degrees, altitude in meters. If ndims is equal to 2 then the altitude is considered to be constant and equal to zero.radius (optional) – The maximum distance in meters to search for neighbors. If not set, the search is performed on all the neighbors.
k – The number of nearest neighbors to return.
within – if true, the method returns the k nearest neighbors if the point is within by its neighbors.
num_threads – The number of threads to use for the computation. If 0 all CPUs are used. If 1 is given, no parallel computing code is used at all, which is useful for debugging. Defaults to
0
.
- Returns:
A tuple containing the coordinates and values of the K-nearest neighbors of the given point.
Note
The matrix containing the coordinates of the neighbors is a matrix of dimension
(k, n)
wheren
is equal to 2 if the provided coordinates matrix defines only longitude and latitude, and 3 if the defines longitude, latitude and altitude.