pyinterp.RTree.query¶
- RTree.query(coordinates: ndarray, k: int = 4, within: bool = True, num_threads: int = 0) tuple[ndarray, ndarray][source]¶
Search for the nearest K nearest neighbors of a given point.
- 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: Ifecef=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 – The number of nearest neighbors to be searched. Defaults to
4.within – If true, the method ensures that the neighbors found are located within the point of interest. Defaults to
false.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 a matrix describing for each provided position, the distance between the provided position and the found neighbors (in meters if the RTree handles LLA coordinates, otherwise in Cartesian units) and a matrix containing the value of the different neighbors found for all provided positions. If no neighbors are found, the distance and the value are set to
-1.