Add optional xarray/rasterio support for indices and sampling - #12
Open
ysims wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
geoextras 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).