raster_tools.dataarray_to_xr_raster_ds#

raster_tools.dataarray_to_xr_raster_ds(xdata, xmask=None, crs=None)[source]#

Create a raster Dataset object from a DataArray object.

The null value is pulled from xdata using rioxarray.

Parameters
  • xdata (xarray.DataArray,) – The object to convert to a raster Dataset

  • xmask (xarray.DataArray[bool], optional) – The matching mask to use with the xdata object when creating the raster Dataset. Must have boolean dtype. The default is to generate a mask from xdata based on the value returned by xdata.rio.nodata.

  • crs (int, str, rasterio.CRS, optional) – The CRS to use when creating the result. The default is to take the CRS from xdata, if present.

Returns

raster – The resulting raster Dataset with two data variables: “raster” and “mask”.

Return type

xarray.Dataset