class uxarray.grid.neighbors.KDTree(grid, coordinates='nodes', coordinate_system='cartesian', distance_metric='minkowski', reconstruct=False)#

Custom KDTree data structure written around the sklearn.neighbors.KDTree implementation for use with corner (node_x, node_y, node_z) and (node_lon, node_lat), edge (edge_x, edge_y, edge_z) and (edge_lon, edge_lat), or center (face_x, face_y, face_z) and (face_lon, face_lat) nodes of the inputted unstructured grid.

  • grid (ux.Grid) – Source grid used to construct the KDTree

  • coordinates (str, default="nodes") – Identifies which tree to construct or select, with “nodes” selecting the corner nodes, “face centers” selecting the face centers of each face, and “edge centers” selecting the centers of each edge of a face

  • coordinate_system (str, default="cartesian") – Sets the coordinate type used to construct the KDTree, either cartesian coordinates or spherical coordinates.

  • distance_metric (str, default="minkowski") – Distance metric used to construct the KDTree, available options include: ‘euclidean’, ‘l2’, ‘minkowski’, ‘p’, ‘manhattan’, ‘cityblock’, ‘l1’, ‘chebyshev’, ‘infinity’

  • reconstruct (bool, default=False) – If true, reconstructs the tree


See sklearn.neighbors.KDTree for further information about the wrapped data structures.

__init__(grid, coordinates='nodes', coordinate_system='cartesian', distance_metric='minkowski', reconstruct=False)#


__init__(grid[, coordinates, ...])

query(coords[, k, return_distance, ...])

Queries the tree for the k nearest neighbors.

query_radius(coords[, r, return_distance, ...])

Queries the tree for all neighbors within a radius r.