add `DataArray.cf.get_pyproj_crs()`
larsbuntemeyer opened this issue · 10 comments
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:
Related issues:
For the cartopy case, this seems to have been an issue for some time now.
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:
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
:
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...
Ahh, nice! Yes, you mentioned that in the roadmap. I'll check it out.
FWIW I'd be happy to add .cf.crs -> pyproj.CRS
and .cf.crs_cartopy
if someone has heuristics for cartopy_crs
lying around.
I started something here for ccrs some time ago (it's the naive approach). Would be happy to move something to cf_xarray!
Pyproj already has almost everything here https://github.com/pyproj4/pyproj/blob/69fb46f2c007f71a3534a7c935b6f8813a45dfa6/pyproj/crs/_cf1x8.py
When I last looked at this, fixing SciTools/cartopy#2099 really looked like the most elegant way forward... Also, if a naive and explicit mapping from CF to Cartopy is the solution, maybe it would be most useful in cartopy
directly ?