windkit.spatial.nearest_points

windkit.spatial.nearest_points(ds_ref: Dataset, ds_target: Dataset, dims=['west_east', 'south_north', 'height'], n_nearest=1, return_rank=False, return_distance=False, keep_duplicates=True)[source]

Get nearest points from dataset in windkit spatial structure

Parameters:
  • ds_ref (xr.Dataset) – Input dataset of which we want to select nearest points

  • ds_target (xr.Dataset) – Target dataset of the points we want to obtain from the input

  • dims (list of strings) – Dimensions which we want to use for nearest neighbour lookup

  • n_nearest (int) – Number of closest points to return for each point in ds_target

  • return_rank (bool) – Return the rank of closeness

  • return_distance (bool) – Return the distance to closest point

  • keep_duplicates (bool, default True) – If True and ds_target is a point structure and there is any duplicates created during the nearest neighbour mapping, these will be kept in the dataset so that the output structure is the same as ds_target. If False, removes them from the data.

Returns:

The points from ds_ref that are nearest to ds_target (i.e. ds will have the same spatial structure as ds_target)

Return type:

xr.Dataset

Raises:

RunTimeError – if the data is not in point format and there is duplicates created during the nearest neighbour mapping.