raster_tools.data_to_xr_raster#

raster_tools.data_to_xr_raster(data, x=None, y=None, affine=None, crs=None, nv=None)[source]#

Create a standard raster DataArray from a data array.

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

  • x (list, np.ndarra, optional) – The x coordinate value. If x and y are not specified, affine is used to generate x and y coordinates.

  • y (list, np.ndarra, optional) – The y coordinate value. If x and y are not specified, affine is used to generate x and y coordinates.

  • affine (affine.Affine, optional) –

    If None, the affine matrix is created using x and y. If affine is None and x and y are not specified, default affine matrix of:

    | 1.0  0.0 0.0 |
    | 0.0 -1.0   N |
    

    where N is the size of the y dim.

  • crs (int, str, rasterio.CRS, optional) – The CRS to use for the result. The default is no CRS.

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

Returns

raster – The resulting raster DataArray.

Return type

xarray.DataArray