Skip to content

Add optional xarray/rasterio support for indices and sampling - #12

Open
ysims wants to merge 1 commit into
mainfrom
feature/xarray-rasterio-support
Open

Add optional xarray/rasterio support for indices and sampling#12
ysims wants to merge 1 commit into
mainfrom
feature/xarray-rasterio-support

Conversation

@ysims

@ysims ysims commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Scene.data's docstring claimed xarray DataArray/Dataset support, but every band-access helper only ever handled a dict[str, list]. Extend _get_band (indices.py, sampling/core.py) and _read_cell (sampling/core.py) to also accept an xarray DataArray (band dimension + matching coordinate) or Dataset, and a rasterio dataset handle (band_names[i] <-> rasterio band i+1), guarded by try/except ImportError so neither package is required. The dict-of-list path is untouched byte-for-byte. Add a geo extras group, document the conventions and known limitations in docs/concepts.md and docs/status.md, and add tests/test_geo_backends.py (skipped per-class via pytest.importorskip-equivalent markers when xarray/rasterio aren't installed).

Scene.data's docstring claimed xarray DataArray/Dataset support, but every
band-access helper only ever handled a dict[str, list]. Extend _get_band
(indices.py, sampling/core.py) and _read_cell (sampling/core.py) to also
accept an xarray DataArray (band dimension + matching coordinate) or
Dataset, and a rasterio dataset handle (band_names[i] <-> rasterio band
i+1), guarded by try/except ImportError so neither package is required.
The dict-of-list path is untouched byte-for-byte. Add a `geo` extras
group, document the conventions and known limitations in docs/concepts.md
and docs/status.md, and add tests/test_geo_backends.py (skipped per-class
via pytest.importorskip-equivalent markers when xarray/rasterio aren't
installed).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant