Skip to content

Add read support for Zarr spatial and proj conventions#905

Open
emmanuelmathot wants to merge 4 commits intocorteva:masterfrom
emmanuelmathot:feature/zarr-convention-read-clean
Open

Add read support for Zarr spatial and proj conventions#905
emmanuelmathot wants to merge 4 commits intocorteva:masterfrom
emmanuelmathot:feature/zarr-convention-read-clean

Conversation

@emmanuelmathot
Copy link
Contributor

@emmanuelmathot emmanuelmathot commented Feb 4, 2026

Add read support for Zarr spatial and proj conventions

This is the second in a series of PRs splitting #883 as requested by maintainers. Depends on #899, #903, #904.

Changes:

  • Add Convention.ZARR enum value to rioxarray.enum
  • Create zarr.py module with ZarrConvention class implementing ConventionProtocol
  • Register ZarrConvention in _core.py's _CONVENTION_MODULES for automatic convention detection
  • Support proj:wkt2, proj:code, proj:projjson for CRS reading
  • Support spatial:transform, spatial:dimensions for transform and dimension reading
  • Convention declaration checking via zarr_conventions attribute

Architecture:

Reviewer feedback addressed:


Future PRs:

  • PR 3: Writing Zarr CRS (write_crs(convention=Convention.Zarr))
  • PR 4: Writing Zarr Transform (write_transform(convention=Convention.Zarr))

- Add Convention.Zarr enum value
- Create _convention/zarr.py module with ZarrConvention class implementing
  ConventionProtocol for reading CRS, transform, and spatial dimensions
- Support proj:wkt2, proj:code, proj:projjson for CRS reading
- Support spatial:transform, spatial:dimensions for transform and dimension reading
- Register ZarrConvention in _core.py's _CONVENTION_MODULES
- Both conventions are tried when reading regardless of setting (priority changes only)
- Add comprehensive unit tests for Zarr convention parsing and reading
- Add integration tests for Zarr convention with rio accessor

Note: Writing support will be implemented in a future PR.
- Rename Convention.Zarr to Convention.ZARR for UPPER_CASE naming style
- Replace broad 'except Exception' with specific exceptions (KeyError, TypeError, ValueError)
@emmanuelmathot emmanuelmathot marked this pull request as ready for review February 4, 2026 19:42
@snowman2 snowman2 added the enhancement New feature or request label Feb 4, 2026
@snowman2 snowman2 added this to the 0.22.0 milestone Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants