raster_tools.data_to_xr_raster_like#

raster_tools.data_to_xr_raster_like(data, xlike, nv=None, match_band_dim=False, match_chunks=True)[source]#

Create a standard raster DataArray based on a template 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.

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

  • match_band_dim (bool, optional) – If data has only 1 band, this will stack data to match the number of bands in xlike. The default is to not match the number of bands.

  • 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 DataArray matcing xlike.

Return type

xarray.DataArray