xoa.geo.get_neighbors#
- xoa.geo.get_neighbors(obj, target, k=None, radius=None, units='m', output='index', **kwargs)[source]#
Find the nearest neighbors of target points, or those within a distance
This builds a
GeoKDTreefor a single query. Build it once instead to make several queries on the same points.- Parameters:
obj (xarray.DataArray, xarray.Dataset, GeoKDTree) – Object with longitude and latitude coordinates, that may be 1D or 2D, or an already built tree
target (xarray.DataArray, xarray.Dataset, tuple) – Object with longitude and latitude coordinates, or a (lon, lat) pair
k (int, None) – Number of neighbors, see
GeoKDTree.query()radius (float, None) – Maximal distance, see
GeoKDTree.query_radius(). With k, it is the maximal distance of the neighbors.units (int, str, distance_units) – Distance units
output ({"index", "dist", "mask"}) – Return the neighbors of each target, or a distance or mask array on the points of obj
kwargs –
sphere_radiusandleafsizeare passed toGeoKDTree, andworkersto the query.
- Returns:
See
GeoKDTree.query()with k,GeoKDTree.query_radius()otherwise.