Cartopy projection from a cube
✨ Feature Request
A convenience function to get an appropriate Cartopy projection from a cube.
Motivation
When plotting a map to the current axes, iris.plot has some logic that figures out the appropriate Cartopy projection and uses it to set up a Cartopy GeoAxes to plot onto (if the current axes isn't already a Cartopy one). This is super convenient and I use it all the time. However, it relies on Matplotlib's implicit API, which is not really how Matplotlib recommends doing things these days.
If this logic could be factored out into its own public function, then users who want to use the recommended explicit API could do so without losing too much convenience.
cartopy_proj = shiny_new_function(cube)
ax = fig.add_subplot(projection=cartopy_proj)
iplt.contourf(cube, axes=ax)
Additional context
I realise there isn't much to this logic, and I could just write my own convenience function for my own use. However, I think it's worth Iris making it as easy as possible for users to follow the recommended practice.
I would be happy to either write or review a PR for this.
Why can't you use cube.coord_system().as_cartopy_crs() or cube.coord_system().as_cartopy_projection() ??
Why can't you use
cube.coord_system().as_cartopy_crs()orcube.coord_system().as_cartopy_projection()??
I think that is illustrated in the logic that iris.plot currently uses: sometimes there isn't a coord system on the cube, in which case we default to PlateCarree(). There are also some extra complications for RotatedGeogCS, though admittedly I've never knowingly used that.
In order to maintain a backlog of relevant issues, we automatically label them as stale after 500 days of inactivity.
If this issue is still important to you, then please comment on this issue and the stale label will be removed.
Otherwise this issue will be automatically closed in 28 days time.
This stale issue has been automatically closed due to a lack of community activity.
If you still care about this issue, then please either:
- Re-open this issue, if you have sufficient permissions, or
- Add a comment stating that this is still relevant and someone will re-open it on your behalf.