-
Notifications
You must be signed in to change notification settings - Fork 96
Add Convention option & extract CF logic to cf.py #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add Convention option & extract CF logic to cf.py #899
Conversation
- Introduced a new `Convention` enum for managing geospatial metadata conventions. - Added CF convention support in the `_convention` module with functions for reading and writing CRS and transforms. - Updated `_options` to include a convention option. - Modified `XRasterBase` to utilize the convention setting for spatial dimension detection and CRS handling. - Implemented unit tests for CF convention functionalities and options.
…tion logic to `_convention/cf.py` module DOC: Update documentation to include `rioxarray.enum` module with members and inheritance
This is the first in a series of PRs splitting corteva#883 as requested by maintainers. **Changes:** - Add `Convention` enum with `CF` value - Add `convention` option to `set_options()` - Create cf.py module with extracted CF read/write logic - Refactor rioxarray.py to use the new CF module This PR establishes the framework for supporting multiple geospatial metadata conventions. Future PRs will add Zarr convention support. --- - [ ] Closes corteva#883 (partial - first of series) - [x] Tests added - [] Fully documented, including history.rst for all changes and rioxarray.rst for new API
|
When reading attributes from a file, it shouldn't be limited by the The |
|
This is a really good strategy: #883 (review). I suggest using this strategy when writing to the xarray object. |
Co-authored-by: Alan D. Snow <[email protected]>
Co-authored-by: Alan D. Snow <[email protected]>
…orm, and spatial dimensions
|
This is looking pretty good. I suggest moving the |
|
This is getting really close @emmanuelmathot. Thanks for your patience. |
…function signatures and usage
…ansform retrieval
…e defaults and improve clarity
…or reading and writing CRS and transform information
|
See pylint complaints: https://github.com/corteva/rioxarray/actions/runs/21526722800/job/62037060257?pr=899 |
Co-authored-by: Alan D. Snow <[email protected]>
Co-authored-by: Alan D. Snow <[email protected]>
Co-authored-by: Alan D. Snow <[email protected]>
Co-authored-by: Alan D. Snow <[email protected]>
|
remaining failing tests atre |
This is the first in a series of PRs splitting #883 as requested by maintainers.
Summary
This PR establishes the framework for supporting multiple geospatial metadata conventions. Reading auto-detects conventions from existing attributes, while writing uses the convention setting.
Changes
New Convention Framework
Conventionenum withCFvalue inrioxarray/enum.pyconventionoption toset_options()for controlling write behaviorConventionProtocolinterface for consistent convention module APIsCF Convention Module (
rioxarray/_convention/cf.py)rioxarray.pyread_crs()- Read CRS from CF grid_mapping coordinateread_transform()- Read transform from GeoTransform attributeread_spatial_dimensions()- Detect spatial dimensions from standard names/attrswrite_crs()- Write CRS with CF conventions (handlesgrid_mapping_namedefaults)write_transform()- Write transform with CF conventions_write_grid_mapping()- Internal helper for grid_mapping encodingAuto-detect Layer (
rioxarray/_convention/__init__.py)read_crs_auto()- Try all convention readers, with legacyattrs['crs']fallbackread_transform_auto()- Try all convention readers, with legacyattrs['transform']fallbackread_spatial_dimensions_auto()- Try all convention readers_get_convention()- Get convention module based on settingRefactored
rioxarray.pycrsproperty now usesread_crs_auto()for auto-detection_cached_transform()now usesread_transform_auto()write_crs()delegates to convention module, acceptsconventionparameterwrite_transform()delegates to convention module, acceptsconventionparameterwrite_grid_mapping()method kept for backwards compatibilityread_spatial_dimensions_auto()API Design Principles
conventionsetting (default: CF) or per-methodconventionparametercrs/transformattrs still supported for reading*,for clarity and API stabilityFiles Changed
rioxarray/enum.py- NewConventionenumrioxarray/_options.py- Addconventionoptionrioxarray/_convention/__init__.py- Convention interface and auto-detect functionsrioxarray/_convention/cf.py- CF convention implementationrioxarray/rioxarray.py- Refactored to use convention modulesrioxarray/_spatial_utils.py- Updatedwrite_crscall withgrid_mapping_nametest/unit/test_convention_cf.py- New unit tests for CF moduletest/unit/test_options.py- Tests forconventionoptiondocs/history.rst- Document changesdocs/rioxarray.rst- Documentenummodule