Skip to content

geotiff: reject tiled=False for VRT output and validate tile_size (#1862)#1865

Merged
brendancol merged 1 commit into
mainfrom
issue-1862
May 14, 2026
Merged

geotiff: reject tiled=False for VRT output and validate tile_size (#1862)#1865
brendancol merged 1 commit into
mainfrom
issue-1862

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Test plan

  • tiled=False with a .vrt path raises ValueError.
  • tile_size=0 with .vrt raises ValueError from _validate_tile_size (no ZeroDivisionError).
  • Default args still succeed for .vrt.
  • Existing VRT writer tests still pass.

)

VRT writes a directory of tiled GeoTIFFs and always tiles, so
tiled=False with a .vrt path now raises ValueError up front instead
of crashing with ZeroDivisionError inside _write_vrt_tiled. tile_size
is also validated unconditionally on the VRT path.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 14, 2026
@brendancol brendancol requested a review from Copilot May 14, 2026 18:08
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 fixes issue #1862 where to_geotiff(..., '.vrt', tiled=False, tile_size=0) produced a ZeroDivisionError deep inside _write_vrt_tiled instead of a clean user-facing error. The fix takes both options suggested in the issue: reject tiled=False for .vrt paths up front, and ensure tile_size is validated on the VRT branch.

Changes:

  • Compute _is_vrt_path once and suppress the misleading "tile_size ignored" warning on VRT paths.
  • Raise ValueError for tiled=False on .vrt paths and re-validate tile_size inside the VRT branch.
  • Add regression tests covering the rejected/validated combinations and a default-args sanity write.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
xrspatial/geotiff/init.py Adds VRT-path detection, early tiled=False rejection, and explicit tile_size validation on the VRT branch.
xrspatial/geotiff/tests/test_to_geotiff_vrt_tiled_validation_1862.py New regression tests verifying the new guards and ensuring default VRT writes still succeed.

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

@brendancol brendancol merged commit 6cae696 into main May 14, 2026
16 checks passed
@brendancol brendancol deleted the issue-1862 branch May 15, 2026 04:39
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.

geotiff: to_geotiff('.vrt', tiled=False, tile_size=0) raises ZeroDivisionError

2 participants