Skip to content
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

Data variable CRS #21

Open
benbovy opened this issue Feb 21, 2025 · 2 comments
Open

Data variable CRS #21

benbovy opened this issue Feb 21, 2025 · 2 comments

Comments

@benbovy
Copy link
Owner

benbovy commented Feb 21, 2025

Currently Dataset.proj("coord_name").crs can be used to access the CRS of either a spatial reference (scalar) coordinate or a CRS-aware indexed coordinate.

This could probably be extended to data variables as well, which may also be CRS-aware if they have spatial dimensions. Dataset.proj("data_var_name").crs could either return:

  • The CRS returned by Dataset.proj("spatial_ref_name").crs if Dataset["data_var_name"].attrs["grid_mapping"] == "spatial_ref_name" (as inspired by CF conventions)
  • Implicitly fallback to Dataset.proj.crs if there is a unique CRS

To set the CRS of a data variable we could reuse Dataset.map_crs(spatial_ref_name=["data_var_name"]), which will basically (re)set the "grip_mapping" attribute of the given data variable(s).

@dcherian
Copy link

I agree with setting the grid_mapping attribute. My general preference is to encourage users to annotate their data properly rather than rely on implicit behaviour.

@benbovy
Copy link
Owner Author

benbovy commented Feb 25, 2025

I agree with your preference, instead of a fallback we could simply raise an error with some clear instructions in the message. Manually annotating data may be tedious, though. It would be nice if we could provide some API to help doing that in an automated but explicit way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants