Skip to content

Commit 3ad1bdd

Browse files
authored
Open collection-level asset referencing virtual icechunk store (#54)
Using STAC Collection and collection-level assets as described in https://nasa-impact.github.io/dse-virtual-zarr-workshop/examples/03_STAC_Collection_for_Virtual_Icechunk_Store.html ```python import pystac import xarray as xr collection = pystac.Collection.from_file("https://raw.githubusercontent.com/stac-utils/xpystac/refs/heads/icechunk/tests/data/virtual-icechunk-collection.json") # Get the latest version of the collection-level asset assets = collection.get_assets(role="latest-version") asset = next(iter(assets.values())) xr.open_dataset(asset) ```
1 parent d0c6239 commit 3ad1bdd

File tree

9 files changed

+1986
-930
lines changed

9 files changed

+1986
-930
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ iterable of items, or output of pystac_client.Client.search.
1313
| file format | one asset (item or collection-level) | one item | many items |
1414
| ----------- | --------- | -------- | ---------- |
1515
| COG | x | x | x |
16-
| zarr | x | | |
17-
| kerchunk | x | x* | x* |
16+
| Zarr | x | | |
17+
| Kerchunk | x | x* | x* |
18+
| virtual Icechunk | x | | |
1819

1920
\* _if stored in item alongside the datacube extension properties_
2021

@@ -43,6 +44,23 @@ asset = item.assets["visual"]
4344
xr.open_dataset(asset)
4445
```
4546

47+
Read from a virtual Icechunk store
48+
49+
```python
50+
import pystac
51+
import xarray as xr
52+
53+
collection = pystac.Collection.from_file(
54+
"https://raw.githubusercontent.com/stac-utils/xpystac/refs/heads/main/tests/data/virtual-icechunk-collection.json"
55+
)
56+
57+
# Get the latest version of the collection-level asset
58+
assets = collection.get_assets(role="latest-version")
59+
asset = next(iter(assets.values()))
60+
61+
xr.open_dataset(asset)
62+
```
63+
4664
Here are a few examples from the [Planetary Computer Docs](https://planetarycomputer.microsoft.com/docs/overview/about) which has some good examples of collection-level assets used to catalog zarr stores and
4765
kerchunk reference files.
4866

pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ Repository = "https://github.com/stac-utils/xpystac"
2727
[dependency-groups]
2828
dev = [
2929
"adlfs>=2024.12.0",
30-
"aiohttp>=3.11.13",
30+
"aiohttp>=3.12.15",
3131
"fsspec>=2025.3.0",
32+
"icechunk>=1.1.5",
33+
"ipython>=9.5.0",
3234
"kerchunk>=0.2.7",
3335
"odc-stac>=0.3.11",
3436
"planetary-computer>=1.0.0",

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def data_cube_kerchunk() -> pystac.ItemCollection:
2424
return pystac.ItemCollection.from_file(path)
2525

2626

27+
@pytest.fixture(scope="module")
28+
def virtual_icechunk() -> pystac.ItemCollection:
29+
path = "tests/data/virtual-icechunk-collection.json"
30+
return pystac.Collection.from_file(path)
31+
32+
2733
@pytest.fixture(scope="module")
2834
def simple_search() -> pystac_client.ItemSearch:
2935
client = pystac_client.Client.open(STAC_URLS["EARTH-SEARCH"])

0 commit comments

Comments
 (0)