Skip to main content

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/v0"
)

search = catalog.search(
    intersects=dict(type="Point", coordinates=[-105.78, 35.79]),
    collections=['sentinel-s2-l2a-cogs'],
    datetime="2020-04-01/2020-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)

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)

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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpystac-0.1.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

xpystac-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file xpystac-0.1.1.tar.gz.

File metadata

  • Download URL: xpystac-0.1.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for xpystac-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b5ffba11ef0f1d630dac34732dd69ec960f3f05e293d308b0d09b698fed21917
MD5 b4a21173bf79bbeceec5c96bb4cc8073
BLAKE2b-256 f84570468feb81c9f599292084b97d5c7de3474ff59c403220c9e2b8bb2b803b

See more details on using hashes here.

Provenance

File details

Details for the file xpystac-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: xpystac-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for xpystac-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8cbf3b7efe33aaabbcfd1a1b25737574a04ea0d3f63cf6964caa998932c70cd7
MD5 6784e134aa26edcfa87e84aa5bf184dd
BLAKE2b-256 d3949d4dc9780536b2043457feb35f66b363f0f622aa61310b814adbae5f2db3

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page