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 (np.ndarray, optional) – The x coordinate values. Must be given together with y. Ignored if affine is given.

  • y (np.ndarray, optional) – The y coordinate values. Must be given together with x. Ignored if affine is given.

  • affine (affine.Affine, optional) –

    The affine matrix used to generate the x and y coordinates. If given, it takes precedence over x and y, which are ignored. If None, the coordinates are taken from x and y. If affine, x, and y are all None, the default affine matrix is:

    | 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