Repository navigation
Description
Describe the bug
open_geotiff(url, window=..., band=...) passes both parameters through to read_to_array, but the HTTP branch at xrspatial/geotiff/_reader.py:1885 calls _read_cog_http(source, overview_level=..., band=..., max_pixels=...) and drops window on the floor. _read_cog_http then hardcodes window=None when calling _fetch_decode_cog_http_tiles at line 1594. The function accepts band but never slices on it.
Three concrete parity gaps with the local eager path:
-
windownever reaches the HTTP fetch. The HTTP path returns the full raster whileopen_geotiffat__init__.py:645-657builds window-sized coords. The result is either a shape mismatch on xarray construction or wrong coords assigned to a full array. -
bandis accepted but unused on the HTTP path. The local path slicesarr[:, :, band]at_reader.py:1963-1964for multi-band arrays. HTTP returns every band. -
PlanarConfiguration=2is not handled on HTTP. The local tile reader iterates over per-band tile groups whenplanar == 2(_reader.py:1437-1438). The HTTP tile-index loop computestile_idx = tr * tiles_across + tcwith no per-band offset, so separate-band COGs fetch the wrong byte ranges and decode with the wrong expected byte count.
Reproduction
```python
from xrspatial.geotiff import open_geotiff
da = open_geotiff("http://example.com/tiled.tif", window=(0, 0, 256, 256))
Returns full-image data, but coords are sized to the window.
```
Expected behavior
read_to_array(url, window=W, band=B) returns the same shape and values as read_to_array(local_path, window=W, band=B) for the same source.
Suggested fix
- Thread
windowthrough_read_cog_httpto_fetch_decode_cog_http_tiles(the helper already accepts it). - Apply
bandafter the array is materialised, matching the local path. - Add per-band tile indexing in the HTTP loop when
planar == 2, mirroring the localband_countlogic.
Add parity tests that read the same COG from disk and from a local HTTP server (e.g. pytest-httpserver) and compare shape and contents for window-only, band-only, window+band, and planar=2 cases.
Additional context
Reported during a code review of the geotiff module against the recent SSRF and typed-error hardening work (#1664, #1662, #1661).
Activity
Orientation guard + drop tifffile from HTTP COG parity tests (#1669)
Forward window/band and handle PlanarConfiguration=2 on HTTP COG reads (
Orientation guard + drop tifffile from HTTP COG parity tests (#1669)
Validate band index in read_to_array for backend parity (#1673)
Validate band index in read_to_array for backend parity (#1673) (#1676)
Forward window/band and handle planar=2 on HTTP COG reads (#1669) (#1680
Validate read_vrt window against VRT extent (#1697)
Validate read_vrt window against VRT extent (#1697) (#1698)
Update VRT window-clamp tests to match post-#1697 reject contract (#1731