dask.array.to_zarr

Contents

dask.array.to_zarr#

dask.array.to_zarr(arr, url, component=None, storage_options=None, region=None, compute=True, return_stored=False, mode='a', **zarr_array_kwargs)[source]#

Save array to the zarr storage format

See https://zarr.readthedocs.io for details about the format.

Parameters:
arr: dask.array

Data to store

url: Zarr Array or str or MutableMapping

Location of the data. A URL can include a protocol specifier like s3:// for remote data. Can also be any MutableMapping instance, which should be serializable if used in multiple processes.

component: str or None

If the location is a zarr group rather than an array, this is the subcomponent that should be created/over-written. If both component and ‘name’ in zarr_array_kwargs are specified, component takes precedence. This will change in a future version.

storage_options: dict

Any additional parameters for the storage backend (ignored for local paths)

overwrite: bool

If given array already exists, overwrite=False will cause an error, where overwrite=True will replace the existing data. Deprecated, please add to zarr_kwargs

region: tuple of slices or None

The region of data that should be written if url is a zarr.Array. Not to be used with other types of url.

compute: bool

See store() for more details.

return_stored: bool

See store() for more details.

mode: Literal[“r+”, “a”, “w”, “w-“]

Keyword argument mode passed to the storage backend when creating a zarr store from a URL string. Only used when url is a string (not when url is already a zarr.Array or MutableMapping instance).

Common options include:
  • 'r+': Read/write, must exist

  • 'a': Read/write, create if doesn’t exist (default)

  • 'w': Create, remove existing data if present

  • 'w-': Create, fail if exists

**zarr_array_kwargs:

Deprecated since version 2025.12.0: Passing storage io-related arguments via **kwargs is deprecated. Please use the mode parameter instead when using **kwargs with the mode keys and corresponding values. read_only is not allowed anymore and will not have an effect.

Keyword arguments passed to Group.create_array() (for zarr v3, where Group is a zarr group) or zarr.create() (for zarr v2). This function automatically sets shape, chunks, and dtype based on the dask array, but these can be overridden.

Common options include:

  • compressor: Compression algorithm (e.g., zarr.Blosc())

  • filters: List of filters to apply

  • fill_value: Value to use for uninitialized portions

  • order: Memory layout (‘C’ or ‘F’)

  • dimension_separator: Separator for chunk keys (‘/’ or ‘.’)

For the complete list of available arguments, see the zarr documentation:

Raises:
ValueError

If arr has unknown chunk sizes, which is not supported by Zarr. If region is specified and url is not a zarr.Array If mode is specified as r.