You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This might be a question out of the scope of the PR, but I'm wondering about the need to raise a warning or something if assign_crs is used without subsequently calling map_crs to avoid getting into logically inconsistent situations. Maybe link map_crs in the assign_crs API docs too?
For example, you can assign_crs without warning or error, but then as soon as you try to access one of the .crs values you hit:
ValueError: found multiple CRS in Dataset or DataArray:
spatial_ref: EPSG:32610
lat: EPSG:4326
I.e., both the new CRS and the coordinates to map that CRS are passed together as a 2-length tuple to .proj.assign_crs(). Note that pyproj.CRS.from_user_input() may also accept a 2-length tuple in the form (‘epsg’, ‘4322’) but that's probably not a big deal.
We could also try to track the CRSes in a Dataset that have been mapped from spatial reference coordinates to other coordinates (or even data variables #21) at the xproj accessor level, but that's tricky to do it right in a lossless way across Xarray operations.
Activity
benbovy commentedon Jun 10, 2025
(copied from the same comment thread)
Maybe we could allow something like this:
I.e., both the new CRS and the coordinates to map that CRS are passed together as a 2-length tuple to
.proj.assign_crs(). Note thatpyproj.CRS.from_user_input()may also accept a 2-length tuple in the form(‘epsg’, ‘4322’)but that's probably not a big deal.We could also try to track the CRSes in a Dataset that have been mapped from spatial reference coordinates to other coordinates (or even data variables #21) at the xproj accessor level, but that's tricky to do it right in a lossless way across Xarray operations.