RTree.query(coordinates: numpy.ndarray, k: Optional[int] = 4, within: Optional[bool] = True, num_threads: Optional[int] = 0) Tuple[numpy.ndarray, numpy.ndarray][source]

Search for the nearest K nearest neighbors of a given point.

  • coordinates (numpy.ndarray) – a matrix (n, ndims) where n is the number of observations and ndims is the number of coordinates in order: longitude and latitude in degrees, altitude in meters and then the other coordinates defined in Euclidean space if dims > 3. If the shape of the matrix is (n, ndims) then the method considers the altitude constant and equal to zero.

  • k (int, optional) – The number of nearest neighbors to be searched. Defaults to 4.

  • within (bool, optional) – If true, the method ensures that the neighbors found are located within the point of interest. Defaults to false.

  • num_threads (int, optional) – 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.


A tuple containing a matrix describing for each provided position, the distance, in meters, between the provided position and the found neighbors and a matrix containing the value of the different neighbors found for all provided positions.

Return type