Skip to content

geotiff: VRT writer does not validate that mosaic sources are compatible #1733

@brendancol

Description

@brendancol

Describe the bug

build_vrt in xrspatial/geotiff/_vrt.py:848 derives the mosaic's resolution, dtype, band count, nodata, and CRS from the first source only:

first = sources_meta[0]
res_x = first['transform'].pixel_width
res_y = first['transform'].pixel_height
...
sf = first['sample_format']
bps = first['bps']
...
n_bands = first['bands']
srs = crs_wkt or first.get('crs_wkt') or ''

The remaining sources are never checked. Mixed pixel sizes, sample formats, band counts, or CRS will produce a syntactically valid VRT that misplaces or mis-types data downstream. Failure is silent.

Expected behavior

Validate that every entry in sources_meta agrees with the first on:

  • pixel width and pixel height (within a small tolerance)
  • sample format and bits per sample (i.e. dtype)
  • band count
  • CRS WKT (when one is set)

Raise a clear error on mismatch. Document nodata precedence between caller arg and per-source value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions