write#

write(raster: Union[numpy.ma.core.MaskedArray, numpy.ndarray], meta: dict, path: Union[str, cloudpathlib.cloudpath.CloudPath, pathlib.Path], **kwargs) None[source]#

Write raster to disk (encapsulation of rasterio’s function)

Metadata will be copied and updated with raster’s information (ie. width, height, count, type…) The driver is GTiff by default, and no nodata value is provided. The file will be compressed if the raster is a mask (saved as uint8)

>>> raster_path = "path/to/raster.tif"
>>> raster_out = "path/to/out.tif"

>>> # Read raster
>>> raster, meta = read(raster_path)

>>> # Rewrite it on disk
>>> write(raster, meta, raster_out)
Parameters
  • raster (Union[np.ma.masked_array, np.ndarray]) – Raster to save on disk

  • meta (dict) – Basic metadata that will be copied and updated with raster’s information

  • path (Union[str, CloudPath, Path]) – Path where to save it (directories should be existing)

  • **kwargs – Overloading metadata, ie nodata=255