raster_tools.data_to_xr_raster_ds_like#

raster_tools.data_to_xr_raster_ds_like(data, xlike, mask=None, nv=None, burn=False, match_chunks=True)[source]#

Create a standard raster Dataset using a template raster DataArray.

The CRS and x/y information are pulled from xlike.

Parameters
  • data (np.ndarray, dask.array.Array) – The data array.

  • xlike (xarray.DataArray) – The template to pull geospatial information from.

  • mask (np.ndarray, dask.array.Array) – A boolean mask array. The default is to generate a mask from the data using nv.

  • nv (scalar, optional) – The nodata/null value to use. The default is no null value.

  • burn (bool, optional) – If True, mask is used to ‘burn’ the null value into the data array (e.g. np.where(mask, nv, data)). The default is False.

  • match_chunks (bool, optional) – If True, the chunks of the output will match the chunks in xlike. The default is True

Returns

raster – The resulting raster Dataset object matching xlike.

Return type

xarray.Dataset