geotiff: VRT writer emits Int64/UInt64 for 64-bit integer sources (#1833)#1835
Open
brendancol wants to merge 1 commit into
Open
geotiff: VRT writer emits Int64/UInt64 for 64-bit integer sources (#1833)#1835brendancol wants to merge 1 commit into
brendancol wants to merge 1 commit into
Conversation
) The dtype lookup in write_vrt had no entry for bps=64, so signed 64-bit sources fell back to Int32 and unsigned 64-bit sources fell back to Byte. The VRT reader has UInt64/Int64 support already (issue #1783), so the loss happened on write -- uint64 values silently truncated to [0, 255]. Add 64-bit entries to both lookups so write_vrt and to_geotiff(..., '*.vrt') round-trip 64-bit integer rasters losslessly.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a writer-only bug where write_vrt lacked a bps=64 entry in the dtype lookup, causing signed int64 to be written as Int32 and uint64 as Byte (truncating values). Adds Int64/UInt64 entries plus regression tests covering dtype emission and round-trip.
Changes:
- Add
64: 'Int64'and64: 'UInt64'entries to the VRT dtype lookup branches inwrite_vrt. - Add regression tests verifying VRT XML
dataTypeand full round-trip for int64/uint64.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| xrspatial/geotiff/_vrt.py | Adds 64-bit entries to the signed/unsigned dtype lookup tables. |
| xrspatial/geotiff/tests/test_vrt_writer_int64_1833.py | New regression tests for int64/uint64 VRT writer emission and round-trip. |
💡 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.
Fixes #1833.
Summary
write_vrt(used byto_geotiff(da, '*.vrt')) emitted the wrong VRTdataTypefor 64-bit integer sources because the lookup at_vrt.py:1366-1368had no entry forbps=64. Signed 64-bit fell back toInt32and unsigned 64-bit fell back toByte-- silently truncating uint64 values to[0, 255]on read-back.UInt64/Int64per geotiff: VRT unknown dataType silently maps to float32 #1783, so the bug was writer-only.Test plan
test_vrt_writer_int64_1833.pyreproduces the bug onmainand passes with the fix.test_vrt_dtype_1783.pyandtest_writer_matrix.pysuites still pass (113 passed).