raster_tools.data_to_raster_like#

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

Create a Raster, based on a template Raster, from a data array.

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

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

  • like (xarray.DataArray, Raster) – The template to pull geospatial information from. Can be a DataArray or Raster.

  • 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 matching like.

Return type

Raster