Skip to content

geotiff: cross-library accuracy test (rasterio vs xarray-spatial vs zarr round-trip) #1961

@brendancol

Description

@brendancol

Test idea

Read the same GeoTIFF three ways and assert the results agree:

  1. rasterio.open(path) → numpy array, transform, CRS, nodata.
  2. xrspatial.geotiff.open_geotiff(path)xr.DataArray.
  3. Write the xarray-spatial DataArray with .to_zarr(...), reopen with xr.open_zarr(...).

Pairwise checks across the three readers:

  • pixel values (array_equal for integer dtypes, allclose with a documented tolerance for floats)
  • shape, dtype, nodata sentinel
  • x and y coordinate arrays within float tolerance
  • CRS WKT after normalising through _resolve_crs_to_wkt
  • affine transform (origin, pixel size) within 1e-9 relative

Why

The project already has backend-parity tests inside its own implementation (numpy / cupy / dask / dask+cupy). What's missing is a test that pins the GeoTIFF reader against an external reference (rasterio) and against a round-trip through a different on-disk format (Zarr). A regression in header parsing, georef extraction, coord generation, nodata handling, or Zarr metadata propagation can pass every existing test and only surface when a user files a bug.

Suggested inputs

Cover the cases that have drifted before:

Suggested location

xrspatial/geotiff/tests/test_round_trip_parity_rasterio_zarr_<issue#>.py

Gate the imports with pytest.importorskip("rasterio") and pytest.importorskip("zarr") so the CPU-only matrix without those deps stays green.

Out of scope

  • performance comparison (handled by the bench skill)
  • GPU read paths (covered by the existing backend parity tests)
  • cloud / HTTP sources (local-file only)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions