pyinterp.RTree.value

Contents

pyinterp.RTree.value#

RTree.value(coordinates: ndarray, radius: float | None = None, k: int = 4, within: bool = True, num_threads: int = 0) tuple[ndarray, ndarray][source]#

Get the coordinates and values for the K-nearest neighbors.

Parameters:
  • coordinates – Array of shape (n, 3) or (n, 2) containing observation coordinates. Here n is the number of observations and each row represents a coordinate in the order x, y, and optionally z. If the matrix shape is (n, 2), the z-coordinate is assumed to be zero. The coordinate system depends on the instance configuration: If ecef=True, coordinates are in the Cartesian coordinate system (ECEF). Otherwise, coordinates are in the geodetic system (longitude, latitude, altitude) in degrees, degrees, and meters, respectively.

  • 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) where n is equal to 2 if the provided coordinates matrix defines only x and y, and 3 if the defines x, y, and z.