raster_tools.data_to_raster#
- raster_tools.data_to_raster(data, mask=None, x=None, y=None, affine=None, crs=None, nv=None, burn=False)[source]#
Create a Raster from a data array.
- Parameters
data (np.ndarray, dask.array.Array) – The data array.
mask (np.ndarray, dask.array.Array) – A boolean mask array. The default is to generate a mask from the data using nv.
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 allNone, 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.
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 isFalse.
- Returns
raster – The resulting Raster object.
- Return type