cf-xarray
cf-xarray copied to clipboard
add `DataArray.cf.get_pyproj_crs()`
Woud be nice to have a cf function that generates CRS from grid_mappings that cartopy can understand for plotting. Would be nice to simply work without having to know which mapping is present, e.g., no need to pick the required cartopy CRS by hand.
Continue the dicussions started here:
- https://github.com/xarray-contrib/cf-xarray/pull/370
- https://github.com/xarray-contrib/cf-xarray/pull/391#discussion_r1085606126
Related issues:
- https://github.com/SciTools/cartopy/issues/2099
For the cartopy case, this seems to have been an issue for some time now.
- https://github.com/SciTools/cartopy/issues/813
I am unsure, why this seems to be complicated (also it should not?)...
A possible workaround before going upstream: we could use a couple of mappings that simply map cf grid_mapping_name to the appropriate cartopy CRS (including **kwargs).
Those of us developing Iris are equally frustrated around this topic:
- SciTools/iris#4643
- SciTools/cartopy#2039
Apologies for my incomplete understanding of this area, I believe the two links I have provided are relevant, although there may be others.
@dcherian I have some code that i now use regularly to do transformations based on grid mappings using pyproj:
https://github.com/euro-cordex/py-cordex/blob/90e18d1bf020b3b869d9d2ffcc7039a63a92f176/cordex/transform.py#L77-L175
I also use that to compute boundaries by transforming the linear x, y boundaries according to the grid mapping info. I was wondering if that could have a place here in a kind of mapping class, e.g., as an option in _guess_bounds... also pinging @aulemahal here...
I think the transformations should be in rioxarray already?
cc @snowman2
Ahh, nice! Yes, you mentioned that in the roadmap. I'll check it out.
https://pyproj4.github.io/pyproj/stable/build_crs_cf.html
https://corteva.github.io/rioxarray/stable/getting_started/crs_management.html