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

CRS handling API #7

Open
3 of 5 tasks
benbovy opened this issue Dec 12, 2024 · 1 comment
Open
3 of 5 tasks

CRS handling API #7

benbovy opened this issue Dec 12, 2024 · 1 comment

Comments

@benbovy
Copy link
Owner

benbovy commented Dec 12, 2024

A tentative API for all CRS specific operations:

  • Dataset.proj.assign_crs(...) : (re-)set a CRS without data transformation
  • Dataset.proj.guess_crs(...) : try setting a new CRS from the metadata of an existing spatial reference (scalar) coordinate.
  • Dataset.proj.to_crs(...) : set a new CRS with data transformation (re-projection)
  • Dataset.proj.write_crs_info(...) : add metadata to a spatial reference coordinate given some "flavor"
  • Dataset.proj.clear_crs_info(...) : remove metadata from a spatial reference coordinate

Alternatively we could expose the same functionality through fewer methods, e.g., assign_crs would guess the CRS from coordinate metadata if no CRS is given, assign_crs may also write metadata depending on a keyword argument, etc. I think I prefer the suggestion above, though (more methods with limited scope and clean API).

We should probably avoid being too opinionated here about how CRS is represented in metadata, but since pyproj supports many formats it would make sense for xproj (= Pyproj Xarray wrapper) to provide convenient API like guess_crs, write_crs_info and clear_crs_info.

@benbovy
Copy link
Owner Author

benbovy commented Jan 9, 2025

Dataset.proj.to_crs(...) may be tricky to support here since it usually involves operations such as resampling (regridding) on raster (gridded) data, which are applied on data variables and may be done in a lot of different ways. It is also not clear to me how it would work together with Dataset.proj.map_crs(transform=True) added in #19.

It is easier if we first restrict XProj's scope to handling spatial reference coordinates and possibly other CRS-aware indexed coordinates via Dataset.proj.map_crs().

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

1 participant