save#

geowombat.save(data, filename, mode='w', nodata=None, overwrite=False, client=None, compute=True, tags=None, compress='none', compression=None, num_workers=1, log_progress=True, tqdm_kwargs=None, bigtiff=None)[source]#

Saves a DataArray to raster using rasterio/dask.

Parameters:
  • filename (str | Path) – The output file name to write to.

  • overwrite (Optional[bool]) – Whether to overwrite an existing file. Default is False.

  • mode (Optional[str]) – The file storage mode. Choices are [‘w’, ‘r+’].

  • nodata (Optional[float | int]) – The ‘no data’ value. If None (default), the ‘no data’ value is taken from the DataArray metadata.

  • client (Optional[Client object]) – A dask.distributed.Client client object to persist data. Default is None.

  • compute (Optinoal[bool]) – Whether to compute and write to filename. Otherwise, return the dask task graph. If True, compute and write to filename. If False, return the dask task graph. Default is True.

  • tags (Optional[dict]) – Metadata tags to write to file. Default is None.

  • compress (Optional[str]) – The file compression type. Default is ‘none’, or no compression.

  • compression (Optional[str]) –

    The file compression type. Default is ‘none’, or no compression.

    Deprecated since version 2.1.4: Use ‘compress’ – ‘compression’ will be removed in >=2.2.0.

  • num_workers (Optional[int]) – The number of dask workers (i.e., chunks) to write concurrently. Default is 1.

  • log_progress (Optional[bool]) – Whether to log the progress bar during writing. Default is True.

  • tqdm_kwargs (Optional[dict]) – Keyword arguments to pass to tqdm.

  • bigtiff (Optional[str]) – A GDAL BIGTIFF flag. Choices are [“YES”, “NO”, “IF_NEEDED”, “IF_SAFER”].

  • data (DataArray) –

Returns:

None, writes to filename

Example

>>> import geowombat as gw
>>>
>>> with gw.open('file.tif') as src:
>>>     result = ...
>>>     gw.save(result, 'output.tif', compress='lzw', num_workers=8)
>>>
>>> # Create delayed write tasks and compute later
>>> tasks = [gw.save(array, 'output.tif', compute=False) for array in array_list]
>>> # Write and close files
>>> dask.compute(tasks, num_workers=8)