You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VRT mosaic: overlapping <ComplexSource>s are not composited with GDAL's nodata-skip semantics — NoData returned where an overlapping source has valid pixels #19
Environment
oxigeo 0.2.3, Rust stable, Linux x86_64
Dataset: VRTWarpedDataset (EPSG:4326 → EPSG:3857, Bilinear) whose is a mosaic VRT built by gdal.BuildVRT from ~90 Byte GeoTIFFs. Neighbouring sources overlap by ~100 px and carry 0 (standard gdalbuildvrt output, including fractional DstRect offsets).
Summary
When a requested pixel falls in a region covered by more than one , and the source oxigeo reads contains NoData (0) there while another overlapping source contains valid data, read_window / read_window_interleaved return NoData instead of falling back to the valid source. It appears only one source is consulted per pixel/window.
GDAL's VRT driver composites overlapping sources with the rule "sources are applied in document order; a source pixel equal to its NODATA value is skipped (does not overwrite)", so the same VRT reads correctly under GDAL (C++ and the gdal Rust bindings).
Reproduction
gdal.BuildVRT a mosaic from two tiles whose extents overlap, tile A being NoData(0) in the overlap and tile B valid (attached z8_200_113_raw.vrt contains many such pairs, e.g. Laos_tile_L10_1600_623.TIF vs Thailand_tile_L10_1599_623.TIF).
gdal.Warp -of VRT to EPSG:3857 (attached z8_199_113.vrt).
oxigeo: Dataset::open(...) + read_window_interleaved::(...) over an overlap band → returns 0/0/0.
GDAL (gdal_translate / gdal crate read_as) over the same window → returns tile B's valid pixels.
Rendered symptom: holes along tile-overlap bands in oxigeo output; seamless imagery under GDAL. Screenshots attached.
Expected behaviour
Implement GDAL compositing semantics in the mosaic reader: initialise the destination with the band NoDataValue, then for each in document order write its pixels except those equal to the source's value, so valid data from any overlapping source survives.
Notes
This is independent of the parsing bugs reported separately (scientific-notation , fractional SrcRect/DstRect); it reproduces even after normalising those values.
Real-world gdalbuildvrt mosaics routinely contain overlapping scenes where one scene's nodata region is covered by another scene's valid pixels, so this affects any production mosaic, not just edge cases.
Attachments: z8_199_113.vrt, z8_199_113_raw.vrt, oxigeo-vs-GDAL render comparison.
Thanks @geoschen — confirmed, and your statement of the expected behaviour was exactly right.
Root cause: three things combined in the non-warped mosaic read path.
crates/oxigeo-drivers/vrt/src/xml.rs::parse_source discarded <NODATA> — it fell into the catch-all skip arm, so VrtSource::nodata was never populated from XML and the value was simply unavailable downstream.
crates/oxigeo-drivers/vrt/src/mosaic.rs::MosaicCompositor::composite marked a destination pixel as covered for every source sample, including ones equal to the source's nodata. Under FirstValid the first source to cover a pixel therefore won even when all it had there was nodata, and no later overlapping source could correct it.
crates/oxigeo-drivers/vrt/src/reader.rs::read_window initialised the destination with zeros rather than the band's NoDataValue, so uncovered pixels read back as 0 regardless of the declared nodata.
Fix:
xml.rs — <NODATA> is parsed off <ComplexSource> into VrtSource::nodata.
mosaic.rs — CompositeParams carries the contributing source's nodata (with_source_nodata), and composite skips samples equal to it: they neither overwrite the destination nor claim coverage, so a later overlapping source still fills the pixel. The comparison is on the decoded value rather than raw bytes, so -0.0 matches a 0.0 nodata and a NaN nodata matches any NaN.
reader.rs — the destination is initialised to the band NoDataValue (matching what read_warped_window already did via InitDest::NoData), and a source with no <NODATA> of its own falls back to the nodata its source dataset declares, which is what GDAL compares against.
Document order still decides between two sources that are both valid — the skip does not turn FirstValid into LastValid.
Verification: new crates/oxigeo-drivers/vrt/tests/issue_19_mosaic_nodata_compositing.rs builds two overlapping GeoTIFF tiles where the first is nodata across the overlap and the second is valid, and asserts the overlap reads back as the second tile's data. Against the pre-fix code that column returns 0 — the holes you rendered. It also covers the source-dataset nodata fallback, first-valid-wins when both sources are valid, and uncovered pixels reading as the band nodata. Affected crates and their dependents: 1509/1509 passing, zero clippy warnings.
One scope note: <ComplexSource>ScaleOffset/ScaleRatio and <LUT> are still not applied, and pixel-function bands take a separate code path this change does not touch. If you hit either, a separate issue would be welcome.
Will ship with the 0.2.4 release (planned for on or after Monday 2026-08-10).
Activity
Fix #19 VRT mosaic nodata-skip compositing for overlapping ComplexSou…
cool-japan commentedon Aug 6, 2026
Thanks @geoschen — confirmed, and your statement of the expected behaviour was exactly right.
Root cause: three things combined in the non-warped mosaic read path.
crates/oxigeo-drivers/vrt/src/xml.rs::parse_sourcediscarded<NODATA>— it fell into the catch-all skip arm, soVrtSource::nodatawas never populated from XML and the value was simply unavailable downstream.crates/oxigeo-drivers/vrt/src/mosaic.rs::MosaicCompositor::compositemarked a destination pixel as covered for every source sample, including ones equal to the source's nodata. UnderFirstValidthe first source to cover a pixel therefore won even when all it had there was nodata, and no later overlapping source could correct it.crates/oxigeo-drivers/vrt/src/reader.rs::read_windowinitialised the destination with zeros rather than the band'sNoDataValue, so uncovered pixels read back as 0 regardless of the declared nodata.Fix:
xml.rs—<NODATA>is parsed off<ComplexSource>intoVrtSource::nodata.mosaic.rs—CompositeParamscarries the contributing source's nodata (with_source_nodata), andcompositeskips samples equal to it: they neither overwrite the destination nor claim coverage, so a later overlapping source still fills the pixel. The comparison is on the decoded value rather than raw bytes, so-0.0matches a0.0nodata and a NaN nodata matches any NaN.reader.rs— the destination is initialised to the bandNoDataValue(matching whatread_warped_windowalready did viaInitDest::NoData), and a source with no<NODATA>of its own falls back to the nodata its source dataset declares, which is what GDAL compares against.Document order still decides between two sources that are both valid — the skip does not turn
FirstValidintoLastValid.Verification: new
crates/oxigeo-drivers/vrt/tests/issue_19_mosaic_nodata_compositing.rsbuilds two overlapping GeoTIFF tiles where the first is nodata across the overlap and the second is valid, and asserts the overlap reads back as the second tile's data. Against the pre-fix code that column returns 0 — the holes you rendered. It also covers the source-dataset nodata fallback, first-valid-wins when both sources are valid, and uncovered pixels reading as the band nodata. Affected crates and their dependents: 1509/1509 passing, zero clippy warnings.One scope note:
<ComplexSource>ScaleOffset/ScaleRatioand<LUT>are still not applied, and pixel-function bands take a separate code path this change does not touch. If you hit either, a separate issue would be welcome.Will ship with the 0.2.4 release (planned for on or after Monday 2026-08-10).