Skip to content

open_asset

Import path: earth2studio.data.stac.open_asset

View source on GitHub

Documentation

Open one item asset as a lazy, dask-backed xarray.DataArray.

Nothing beyond the file header is read until values are requested, so windowing (.rio.clip_box, .isel) before .compute() fetches only the COG tiles covering that window. The array keeps the asset's native grid and CRS (da.rio.crs, da.rio.transform()).

Parameters:

  • item (Item) –

    Item returned by search_items.

  • asset (str) –

    Asset key, e.g. "red".

  • provider (StacProvider | None, default: None ) –

    Provider whose sign turns the href into a GDAL path; inferred from the href host when None, by default None

  • chunks (int | Mapping[str, int] | None, default: 1024 ) –

    Dask chunk size; an int is used for both x and y. Match the COG's internal block size for best throughput. None loads eagerly, by default 1024

  • rescale (bool, default: True ) –

    Apply the STAC raster:bands scale/offset (or, failing that, the file's own scale/offset tags) so values are in physical units, by default True

  • mask_nodata (bool, default: True ) –

    Replace raster:bands/file nodata with NaN, by default True

Returns:

  • DataArray –

    (time, y, x) for single-band assets, else (time, band, y, x) (no time when the item has neither datetime nor start_datetime); float32 (float64 for 32/64-bit inputs) when values are rescaled or masked, otherwise the file dtype.

Examples using earth2studio.data.stac.open_asset