Skip to content

Forward VRT kwargs from read_geotiff_dask#1805

Merged
brendancol merged 3 commits into
mainfrom
issue-1797
May 13, 2026
Merged

Forward VRT kwargs from read_geotiff_dask#1805
brendancol merged 3 commits into
mainfrom
issue-1797

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

@brendancol brendancol commented May 13, 2026

Closes #1795.

For direct read_geotiff_dask calls on .vrt sources, forwards window, band, and max_pixels to read_vrt instead of silently dropping them.

Tested: pytest xrspatial/geotiff/tests/test_read_geotiff_dask_vrt_kwargs_1795.py

@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 13, 2026
@brendancol brendancol requested a review from Copilot May 13, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the GeoTIFF Dask reader’s .vrt fast-path so that direct read_geotiff_dask(<something>.vrt, ...) calls no longer drop important keyword arguments. It ensures VRT reads behave consistently with non-VRT reads when callers specify windowing, band selection, or pixel caps.

Changes:

  • Forward window, band, and max_pixels from read_geotiff_dask() to read_vrt() when the source is a .vrt.
  • Add regression tests to validate that direct .vrt reads respect window/band and enforce max_pixels.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
xrspatial/geotiff/__init__.py Forwards VRT-relevant kwargs in the .vrt early-return branch of read_geotiff_dask.
xrspatial/geotiff/tests/test_read_geotiff_dask_vrt_kwargs_1797.py Adds tests covering window/band forwarding and max_pixels enforcement for direct .vrt reads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 2151 to +2160
# ``open_geotiff`` already routes ``.vrt`` to ``read_vrt`` before
# reaching here, so this branch is only hit when ``read_geotiff_dask``
# is called directly with a VRT path. Keep it as a defensive fallback
# rather than letting the windowed-read path try to parse VRT XML as
# TIFF bytes. ``read_vrt`` is the single source of truth for VRT.
if isinstance(source, str) and source.lower().endswith('.vrt'):
return read_vrt(source, dtype=dtype, name=name, chunks=chunks)
return read_vrt(
source, dtype=dtype, window=window, band=band, name=name,
chunks=chunks, max_pixels=max_pixels,
)
@brendancol brendancol merged commit c5afd18 into main May 13, 2026
1 of 11 checks passed
brendancol added a commit that referenced this pull request May 13, 2026
Resolves conflict in xrspatial/geotiff/__init__.py: keeps the
`_read_vrt_dask` dispatch hook from the PR branch. All other
geotiff changes from main (#1791, #1793, #1801, #1802, #1803, #1804,
#1805, #1806) were already integrated into the working tree by the
prior 7329dd9 commit; this merge just records the parent so git
recognises the reconciliation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct read_geotiff_dask on VRT drops window band and max_pixels kwargs

2 participants