Skip to content

geotiff: VRT writer emits Int64/UInt64 for 64-bit integer sources (#1833)#1835

Open
brendancol wants to merge 1 commit into
mainfrom
issue-1833
Open

geotiff: VRT writer emits Int64/UInt64 for 64-bit integer sources (#1833)#1835
brendancol wants to merge 1 commit into
mainfrom
issue-1833

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Fixes #1833.

Summary

  • write_vrt (used by to_geotiff(da, '*.vrt')) emitted the wrong VRT dataType for 64-bit integer sources because the lookup at _vrt.py:1366-1368 had no entry for bps=64. Signed 64-bit fell back to Int32 and unsigned 64-bit fell back to Byte -- silently truncating uint64 values to [0, 255] on read-back.
  • The VRT reader already supports UInt64/Int64 per geotiff: VRT unknown dataType silently maps to float32 #1783, so the bug was writer-only.
  • Adds 64-bit entries to both branches of the lookup. uint64 / int64 rasters now round-trip losslessly.

Test plan

  • New regression test test_vrt_writer_int64_1833.py reproduces the bug on main and passes with the fix.
  • Full test_vrt_dtype_1783.py and test_writer_matrix.py suites still pass (113 passed).

)

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.
@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 04:20
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

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' and 64: 'UInt64' entries to the VRT dtype lookup branches in write_vrt.
  • Add regression tests verifying VRT XML dataType and 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.

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.

VRT writer maps 64-bit integer rasters to wrong dtype

2 participants