save#
- geowombat.save(data, filename, overwrite=False, scatter=None, 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:
data (xarray.DataArray) – The data to write.
filename (str | Path) – The output file name to write to.
overwrite (Optional[bool]) – Whether to overwrite an existing file. Default is False.
scatter (Optional[str]) – Scatter ‘band’ or ‘time’ to separate file. Default is None.
client (Optional[Client object]) – A
dask.distributed.Clientclient object to persist data. Default is None.compute (Optinoal[bool]) – Whether to compute and write to
filename. Otherwise, return thedasktask graph. IfTrue, compute and write tofilename. IfFalse, return thedasktask graph. Default isTrue.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.
Note
When using a client, it is advised to use threading. E.g.,
dask.distributed.LocalCluster(processes=False). Process-based concurrency could result in corrupted file blocks.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”].
- Returns:
None, writes tofilename
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)