hydromt.DataArray.raster.nearest_index#

DataArray.raster.nearest_index(dst_crs=None, dst_res=None, dst_transform=None, dst_width=None, dst_height=None, align=False)#

Prepare nearest index mapping for reprojection of a gridded timeseries file.

Powered by pyproj and k-d tree lookup. Index mappings typically are used in reprojection workflows of time series, or combinations of time series.

… Note: Is used by reproject() if method equals ‘nearest_index’

Parameters:
  • dst_crs (int, dict, or str, optional) – Target CRS. Accepts EPSG codes (int or str); proj (str or dict) or wkt (str). “utm” is accepted and will return the centroid utm zone CRS.

  • dst_res (tuple (x resolution, y resolution) or float, optional) – Target resolution, in units of the target CRS.

  • dst_transform (affine.Affine(), optional) – Target affine transformation. Will be calculated if None.

  • dst_width (int, optional) – Output file width in pixels. Can’t be used together with resolution dst_res.

  • dst_height (int, optional) – Output file height in lines. Can’t be used together with resolution dst_res.

  • align (bool, optional) – If True, align the target transform to the resolution.

Returns:

index – DataArray with flat indices of the source DataArray.

Return type:

xarray.DataArray of intp

Raises:

ValueError – If the destination grid and CRS are not valid.

Notes

  • The method is powered by pyproj and k-d tree lookup.

  • The index mappings are typically used in reprojection workflows of
    time series or combinations of time series.