Skip to main content

zarrextract

zarrextract extracts points, time series and bounding boxes from Zarr stores into Apache Arrow tables. It is a lighter alternative to xarray.open_zarr(...).sel(...) for the common case where you only want a small piece of a large store, and it needs only zarr, pyarrow and numpy.

It requires Python 3.12 or newer.

pip install zarrextract

Usage

The examples assume a store with time, lat and lon coordinates and a variable t2m with those dimensions.

Describe a store

describe() lists the arrays in a store without reading any data.

import zarrextract as zx

description = zx.describe("era5.zarr")
for array in description:
    print(array.name, array.dimensions, array.shape, array.dtype)

description["t2m"].chunks
description.coordinates  # the 1-D coordinate arrays
description.data_variables  # everything else

Arrays in nested groups are listed by their path, which is what extract() takes. For example, an OME-Zarr image keeps its data in 0/0:

description = zx.describe("image.zarr")
print(description["0/0"].dimensions)  # ('t', 'c', 'z', 'y', 'x')
series = zx.extract("image.zarr", "0/0", c=0, z=0, y=100, x=100)

zx.describe("image.zarr", max_depth=0)  # top-level arrays only

Some servers cannot list a group. describe() then uses the consolidated metadata, and raises StoreOpenError if there is none. extract() still works there if you know the array's path.

Extract data

zx.extract(store, variable, **selections) returns a pyarrow.Table in long format: one column per dimension of the variable, then a column for the variable itself, with one row per value. Each keyword names a dimension:

  • a single value picks the nearest coordinate;
  • a (start, stop) pair picks every value from start to stop, inclusive;
  • a dimension without a keyword is kept whole.
import zarrextract as zx

# A point
point = zx.extract("era5.zarr", "t2m", lat=51.5, lon=-0.1, time="2020-06-01")

# A time series at one location
series = zx.extract(
    "era5.zarr", "t2m", lat=51.5, lon=-0.1, time=("2020-01-01", "2020-12-31")
)

# A bounding box at one time
box = zx.extract("era5.zarr", "t2m", lat=(50, 52), lon=(-1, 1), time="2020-06-01")

Coordinates are assumed to be sorted, ascending or descending. Long coordinates are searched by bisection, which gives wrong results on unsorted values.

Longitudes are converted to the store's convention (0 to 360 or -180 to 180). CF time coordinates become Arrow timestamps, scale_factor and add_offset are applied, and _FillValue and missing_value become nulls. In Zarr v2 stores the fill value in the array metadata also becomes null, as in xarray. Only the chunks that overlap the selection are read.

A longitude range may cross the edge of the store's longitude axis. On a store that uses 0 to 360, lon=(-10, 10) gives the longitudes 350 to 359.75 and then 0 to 10, in that order, and reads only the chunks it needs:

box = zx.extract("era5.zarr", "t2m", lat=(50, 52), lon=(-10, 10), time="2020-06-01")

Write to Parquet

import pyarrow.parquet as pq

pq.write_table(series, "series.parquet")

Stores

Local paths work as they are. URLs need fsspec and the backend for their protocol, for example s3fs for s3:// or gcsfs for gs://.

pip install "zarrextract[s3]"    # s3fs, for s3://
pip install "zarrextract[http]"  # fsspec and aiohttp, for http:// and https://
table = zx.extract("s3://bucket/era5.zarr", "t2m", lat=51.5, lon=-0.1)

The backend finds credentials in its usual way, for example from environment variables or a configuration file. To pass options to the backend, use the keyword-only storage_options argument of describe() and extract(). For example, to read a public bucket without credentials:

table = zx.extract(
    "s3://bucket/era5.zarr",
    "t2m",
    lat=51.5,
    lon=-0.1,
    storage_options={"anon": True},
)

storage_options is not a selection, so a dimension cannot be called storage_options.

Limitations

  • Only the standard, gregorian and proleptic_gregorian calendars are supported, and standard or gregorian dates before 1582-10-15 are not.
  • Coordinates are looked up at the top level of the store, so arrays in nested groups are selected by index unless the store has a top-level coordinate of the same name.
  • Dask is not supported.

Licence

BSD-3-Clause. See LICENSE.

Metadata

Release files for zarrextract 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zarrextract 0.2.0
File Size Uploaded Provenance Actions
zarrextract-0.2.0.tar.gz 18.7 kB With provenance Details for zarrextract-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zarrextract 0.2.0
File Interpreter ABI Platform Actions
zarrextract-0.2.0-py3-none-any.whl Python 3 none any Details for zarrextract-0.2.0-py3-none-any.whl

Total release size: 40.0 kB

Release files / zarrextract-0.2.0.tar.gz

Download URL zarrextract-0.2.0.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
73f2c2555af23b87bec688f1d7503094c7df50f2a7e0d1e25bc35cfbc383b5dc
BLAKE2b-256 checksum
How to use checksums
0383f541b128643e0f9996bfd6cc93c49115fce4e700aad175845d49e66613ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / zarrextract-0.2.0-py3-none-any.whl

Download URL zarrextract-0.2.0-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b45b17b92def676519d9718fbc584ae57d70a6a29deb40724eef7d1b2e4cc0e
BLAKE2b-256 checksum
How to use checksums
0691213fe10d4ce135c94f433ecf5f72c865eacf88d7f32b3c82638cf463066d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.18

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 25, 2026.

Transparency log

Security for zarrextract 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zarrextract-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitLab CI/CD, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page