diff --git a/odc/loader/_rio.py b/odc/loader/_rio.py index 1b7a032..ae07012 100644 --- a/odc/loader/_rio.py +++ b/odc/loader/_rio.py @@ -101,8 +101,9 @@ def read( cfg: RasterLoadParams, dst_geobox: GeoBox, dst: Optional[np.ndarray] = None, + selection: Optional[slice] = None, ) -> Tuple[NormalizedROI, np.ndarray]: - return rio_read(self._src, cfg, dst_geobox, dst=dst) + return rio_read(self._src, cfg, dst_geobox, dst=dst, selection=selection) class RioDriver: @@ -426,6 +427,7 @@ def rio_read( cfg: RasterLoadParams, dst_geobox: GeoBox, dst: Optional[np.ndarray] = None, + selection: Optional[slice] = None, ) -> Tuple[NormalizedROI, np.ndarray]: """ Internal read method. @@ -450,7 +452,7 @@ def rio_read( """ try: - return _rio_read(src, cfg, dst_geobox, dst) + return _rio_read(src, cfg, dst_geobox, dst, selection=selection) except ( rasterio.errors.RasterioIOError, rasterio.errors.RasterBlockError, @@ -491,10 +493,12 @@ def _rio_read( cfg: RasterLoadParams, dst_geobox: GeoBox, dst: Optional[np.ndarray] = None, + selection: Optional[slice] = None, ) -> Tuple[NormalizedROI, np.ndarray]: # if resampling is `nearest` then ignore sub-pixel translation when deciding # whether we can just paste source into destination ttol = 0.9 if cfg.nearest else 0.05 + assert selection is None, "Band selection not implemented in rio_read" with rasterio.open(src.uri, "r", sharing=False) as rdr: assert isinstance(rdr, rasterio.DatasetReader) diff --git a/odc/loader/testing/fixtures.py b/odc/loader/testing/fixtures.py index 529655e..bf326b4 100644 --- a/odc/loader/testing/fixtures.py +++ b/odc/loader/testing/fixtures.py @@ -149,9 +149,12 @@ def read( cfg: RasterLoadParams, dst_geobox: GeoBox, dst: Optional[np.ndarray] = None, + selection: Optional[slice] = None, ) -> Tuple[NormalizedROI, np.ndarray]: meta = self._src.meta assert meta is not None + # TODO: handle selection + assert selection is None extra_dims = self._extra_dims() prefix_dims: Tuple[int, ...] = () diff --git a/odc/loader/types.py b/odc/loader/types.py index 8689853..8e5a295 100644 --- a/odc/loader/types.py +++ b/odc/loader/types.py @@ -367,6 +367,7 @@ def read( cfg: RasterLoadParams, dst_geobox: GeoBox, dst: Optional[np.ndarray] = None, + selection: Optional[slice] = None, ) -> Tuple[NormalizedROI, np.ndarray]: ...