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 (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 isNoneand 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.
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