odc-stac icon indicating copy to clipboard operation
odc-stac copied to clipboard

Feature request - support xarray creation direct from stacgeoparquet

Open alexgleith opened this issue 4 months ago • 0 comments
trafficstars

There are some folks doing STAC in GeoParquet files, see: https://github.com/stac-utils/rustac-py

You can load this into an xarray using odc.stac.load as shown in the below code.

import rustac
import pystac
from odc.stac import load

url = "https://data.source.coop/ausantarctic/ghrsst-mur-v2/ghrsst-mur-v2.parquet"

year = 2025

dicts = await rustac.read(url)
items = [pystac.Item.from_dict(d) for d in dicts["features"]]
less_items = [i for i in items if i.datetime.year == year]

print(f"Found {len(items)} items, filtered to {len(less_items)} items for {year}")

data = load(
    less_items,
    chunks={"longitude": 4000, "latitude": 4000, "time": 1},
    measurements=["analysed_sst"],
    fail_on_error=False
)

data

We could shortcut this by supporting a parquet file in the load function, so odc.stac.load("https://example.com/stac.parquet") and handle all the filtering and so on. It would be pretty neat!

alexgleith avatar Jul 01 '25 05:07 alexgleith