pyinterp.rtree.query

Contents

pyinterp.rtree.query#

pyinterp.rtree.query(tree, coordinates, config=None, *, k=None, radius=None, boundary_check=None, num_threads=None)[source]#

Query nearest neighbors.

Parameters:
  • tree (core.RTree3DHolder | core.geometry.geographic.RTree) – R*Tree containing the scattered data.

  • coordinates (np.ndarray[TwoDims, np.dtype]) –

    Query coordinates as a NumPy array with shape:

    • (N, 2): For geographic.RTree, representing (longitude, latitude).

    • (N, 2) or (N, 3): For RTree3DHolder, representing (longitude, latitude[, altitude]).

  • config (rtree.Query | None) – Configuration object (if provided, keyword args are ignored)

  • k (int | None) – Number of nearest neighbors to return

  • radius (float | None) – Search radius (None = no limit)

  • boundary_check (BoundaryCheck | None) – Boundary checking mode

  • num_threads (int | None) – Number of threads (0 = auto)

Returns:

Tuple of (distances, values) arrays

Return type:

tuple[np.ndarray[TwoDims, np.dtype], np.ndarray[TwoDims, np.dtype]]

Examples

>>> distances, values = query(tree, coords, k=5)