pyinterp.core.RTree3DFloat64.query

pyinterp.core.RTree3DFloat64.query#

RTree3DFloat64.query(self: pyinterp.core.RTree3DFloat64, coordinates: Annotated[numpy.typing.ArrayLike, numpy.float64], k: SupportsInt = 4, within: bool = False, num_threads: SupportsInt = 0) tuple#

Find the K nearest neighbors of given points.

Searches for the nearest neighbors to the provided coordinates in the spatial index.

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.

  • k – Number of nearest neighbors to return. Defaults to 4.

  • within – If True, ensures that neighbors are located around the point of interest (no extrapolation). Defaults to False.

  • num_threads – Number of threads to use for computation. If 0, all CPUs are used. If 1, no parallel computing is used (useful for debugging). Defaults to 0.

Returns:

Tuple containing (1) a matrix of distances between each provided position and the found neighbors (in meters for LLA coordinates, Cartesian units for ECEF), and (2) a matrix of values for the neighbors found.