xoa.geo.GeoSelector.nearest#
- GeoSelector.nearest(lon, lat, max_dist=None, units='m', valid=None)[source]#
Select the points that are the closest to target points
- Parameters:
lon (float, array_like) – Target longitudes and latitudes, scalars or 1D arrays
lat (float, array_like) – Target longitudes and latitudes, scalars or 1D arrays
max_dist (float, None) – Maximal distance in units
units ({"m", "km"}) – Units of distances
valid (None, xarray.DataArray) – Boolean mask of the points that can be selected, with the horizontal dimensions, like the sea points or those that have data, see
get_valid_mask(). The search is cached for each mask.
- Returns:
GeoSelection – With scalar targets, the indexers are integers like
isel(lon=3, lat=7). With 1D targets, they are data arrays for a pointwise selection, which are -1 for targets without neighbor, where the distance is infinite.