Skip to content

GeoTIFF: centralize VRT capability validation (#2321 sub-task 2) #2329

@brendancol

Description

@brendancol

Sub-task of #2321.

VRT capability checks are scattered across read_vrt (in _backends/vrt.py) and the open_geotiff .vrt branch, and some checks fire only once a chunk is actually decoded. That means a malformed VRT can build a dask graph successfully and then blow up inside a chunk function, far from the call site.

Add a single validator that runs against an already-parsed VRTDataset before any read work starts. It should cover:

  • CRS compatibility
  • dtype compatibility across bands
  • band count sanity
  • nodata policy
  • transform orientation (flips the read path does not honour)
  • pixel-size compatibility
  • SrcRect vs DstRect sanity
  • the supported resampling set

Both read_vrt and open_geotiff('foo.vrt') should call the validator so the two entry points produce the same rejections. Raise a typed VRTUnsupportedError (a subclass of the existing geotiff error class in _errors.py) and put the offending source path and field name in the message.

The validator must accept already-parsed structures. Do not re-parse the VRT XML inside it.

Acceptance

  • Unsupported VRT features raise at graph build or eager-read setup, not deep in a chunk function.
  • read_vrt(bad.vrt) and open_geotiff('bad.vrt') produce the same error type and message for the same input.
  • One negative test per validator rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgeotiffGeoTIFF modulevrtVRT support contract

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions