geotiff: reject tiled=False for VRT output and validate tile_size (#1862)#1865
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_pathonce and suppress the misleading "tile_size ignored" warning on VRT paths. - Raise
ValueErrorfortiled=Falseon.vrtpaths and re-validatetile_sizeinside 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.
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.
Summary
to_geotiff(..., '.vrt', tiled=False, ...)now raisesValueErrorup front. VRT output is always tiled, so a strip-mode request was never honored anyway.tile_sizeis validated unconditionally for.vrtpaths, sotile_size=0no longer reaches_write_vrt_tiledand triggersZeroDivisionError.Test plan
tiled=Falsewith a.vrtpath raisesValueError.tile_size=0with.vrtraisesValueErrorfrom_validate_tile_size(noZeroDivisionError)..vrt.