Skip to content

Commit 7851a4f

Browse files
authored
Support Kerchunk indices embedded in STAC items (#33)
Closes: #32 This PR supports the following: ```python import pystac import xarray as xr path = "https://raw.githubusercontent.com/stac-utils/xpystac/kerchunk/tests/data/data-cube-kerchunk-item-collection.json" item_collection = pystac.ItemCollection.from_file(path) ds = xr.open_dataset(item_collection) ds ```
1 parent 1f36077 commit 7851a4f

File tree

10 files changed

+16228
-4
lines changed

10 files changed

+16228
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ dist
77
.pytest_cache
88
.ruff_cache
99
*.egg-info/
10-
.venv
10+
.venv

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ xr.open_dataset(asset, patch_url=planetary_computer.sign)
6262
```
6363
ref: https://planetarycomputer.microsoft.com/docs/quickstarts/reading-zarr-data/
6464

65+
66+
Here is an example using the new approach of storing kerchunked metadata within the data-cube extension:
67+
68+
```python
69+
import pystac
70+
import xarray as xr
71+
72+
path = "https://raw.githubusercontent.com/stac-utils/xpystac/main/tests/data/data-cube-kerchunk-item-collection.json"
73+
item_collection = pystac.ItemCollection.from_file(path)
74+
75+
ds = xr.open_dataset(item_collection)
76+
ds
77+
```
78+
79+
6580
## Install
6681

6782
```bash

environment.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: xpystac
2+
channels:
3+
- conda-forge
4+
- nodefaults
5+
dependencies:
6+
- python
7+
# required
8+
- pystac
9+
- xarray
10+
# optional
11+
- adlfs
12+
- aiohttp
13+
- fsspec
14+
- kerchunk
15+
- odc-stac
16+
- planetary-computer
17+
- pystac-client
18+
- requests
19+
- rioxarray
20+
- stackstac
21+
- urllib3<2 # temporary pin https://github.com/stac-utils/pystac-client/issues/509
22+
- zarr
23+
# testing
24+
- pytest
25+
- pytest-cov
26+
- pytest-vcr

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dev = [
2929
"adlfs>=2024.12.0",
3030
"aiohttp>=3.11.13",
3131
"fsspec>=2025.3.0",
32+
"kerchunk>=0.2.7",
3233
"odc-stac>=0.3.11",
3334
"planetary-computer>=1.0.0",
3435
"pre-commit>=4.0.1",

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ def simple_cog(simple_item) -> pystac.Asset:
1818
return asset
1919

2020

21+
@pytest.fixture(scope="module")
22+
def data_cube_kerchunk() -> pystac.ItemCollection:
23+
path = "tests/data/data-cube-kerchunk-item-collection.json"
24+
return pystac.ItemCollection.from_file(path)
25+
26+
2127
@pytest.fixture(scope="module")
2228
def simple_search() -> pystac_client.ItemSearch:
2329
client = pystac_client.Client.open(STAC_URLS["EARTH-SEARCH"])

0 commit comments

Comments
 (0)