Extend xarray.open_dataset to accept pystac objects
Project description
xpystac
xpystac provides the glue that allows xarray.open_dataset to accept pystac objects.
The goal is that as long as this library is in your env, you should never need to think about it.
Example
Search collection of COGs:
import pystac_client
import xarray as xr
catalog = pystac_client.Client.open(
"https://earth-search.aws.element84.com/v1",
)
search = catalog.search(
intersects=dict(type="Point", coordinates=[-105.78, 35.79]),
collections=['sentinel-2-l2a'],
datetime="2022-04-01/2022-05-01",
)
xr.open_dataset(search, engine="stac")
Here are a few examples from the Planetary Computer Docs
import planetary_computer
import pystac_client
import xarray as xr
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
Read from a reference file:
collection = catalog.get_collection("nasa-nex-gddp-cmip6")
asset = collection.assets["ACCESS-CM2.historical"]
xr.open_dataset(asset, patch_url=planetary_computer.sign)
ref: https://planetarycomputer.microsoft.com/dataset/nasa-nex-gddp-cmip6#Example-Notebook
Read from a zarr file:
collection = catalog.get_collection("daymet-daily-hi")
asset = collection.assets["zarr-abfs"]
xr.open_dataset(asset, patch_url=planetary_computer.sign)
ref: https://planetarycomputer.microsoft.com/docs/quickstarts/reading-zarr-data/
Install
pip install git+https://github.com/stac-utils/xpystac
How it works
When you call xarray.open_dataset(object, engine="stac") this library maps that open call to the correct library.
Depending on the type of object that might be a stacking library (either
odc-stac or stackstac)
or back to xarray.open_dataset itself but with the engine and other options pulled from the pystac object.
Prior Art
This work is inspired by https://github.com/TomAugspurger/staccontainers and the discussion in https://github.com/stac-utils/pystac/issues/846
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xpystac-0.2.0.tar.gz.
File metadata
- Download URL: xpystac-0.2.0.tar.gz
- Upload date:
- Size: 121.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c6b98c8c70af37132c629c8e7d642a33df88ce99ae24d1b97ccdc46bb370f1
|
|
| MD5 |
769cea959ba5422476429a9d4c7025b1
|
|
| BLAKE2b-256 |
7d6bad4ba3747c1be7f476ebcd5afd2ca5bccba69c7e436700ac38283e770e68
|
File details
Details for the file xpystac-0.2.0-py3-none-any.whl.
File metadata
- Download URL: xpystac-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1da44fb273b47235b027ff5749430e088525bea73a8d9e0955180eeb7f1334c
|
|
| MD5 |
8b07f5c0921d4c554c3248908007210a
|
|
| BLAKE2b-256 |
24679c44b4798cd5d0dbc45243318cf89482b043ed05dec12c59558b3a04aab8
|