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

add DataArray.cf.get_pyproj_crs() #395

Open
larsbuntemeyer opened this issue Jan 24, 2023 · 10 comments
Open

add DataArray.cf.get_pyproj_crs() #395

larsbuntemeyer opened this issue Jan 24, 2023 · 10 comments

Comments

@larsbuntemeyer
Copy link
Contributor

larsbuntemeyer commented Jan 24, 2023

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:

@dcherian dcherian changed the title add cf.get_pyproj_crs() add DataArray.cf.get_pyproj_crs() Jan 24, 2023
@larsbuntemeyer
Copy link
Contributor Author

larsbuntemeyer commented Jan 27, 2023

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).

@trexfeathers
Copy link

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.

@larsbuntemeyer
Copy link
Contributor Author

@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...

@dcherian
Copy link
Contributor

I think the transformations should be in rioxarray already?

cc @snowman2

@larsbuntemeyer
Copy link
Contributor Author

Ahh, nice! Yes, you mentioned that in the roadmap. I'll check it out.

@snowman2
Copy link
Member

@snowman2
Copy link
Member

https://corteva.github.io/rioxarray/stable/getting_started/crs_management.html

@dcherian
Copy link
Contributor

dcherian commented Jun 26, 2024

FWIW I'd be happy to add .cf.crs -> pyproj.CRS and .cf.crs_cartopy if someone has heuristics for cartopy_crs lying around.

@larsbuntemeyer
Copy link
Contributor Author

larsbuntemeyer commented Jun 26, 2024

I started something here for ccrs some time ago (it's the naive approach). Would be happy to move something to cf_xarray!

@aulemahal
Copy link
Contributor

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 ?

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

5 participants