Question

Is it possible to plot contours over a polar stereographic map with the latest version of cartopy? I'd like to see an example of how this is done as I'm struggling to work it out myself!

Was it helpful?

Solution

The stereographic projection is causing a couple of headaches and is probably the projection which has raised the most issues for cartopy's polygon transformations code.

The following example show how one should produce a polar stereographic plot with cartopy. Please note: even with this code, it is possible to tweak the sample data resolution and find that the plot takes ~30 minutes to actually render (that is a bug which we will need to sort sooner rather than later).

import cartopy.crs as ccrs
import matplotlib.pyplot as plt

from cartopy.examples.waves import sample_data

ax = plt.axes(projection=ccrs.NorthPolarStereo())

x, y, z = sample_data((100, 200))
cs = ax.contourf(x, y, z, 50,
                 transform=ccrs.PlateCarree(),
                 cmap='gist_ncar')
ax.coastlines()

# without the set_global, currently, the plot is tiny because the limits
# are being erroneously being set (opened issue for that)
ax.set_global()

plt.show()

polar stereographic contour plot

Hopefully that will show you how one should make a polar stereographic contour plot in cartopy. If you having problems with your data have a look at the open issues tagged "Geometry transforms" and see if you are getting something similar, if not, go ahead and open an issue and we can look into it.

Note: This answer is relating to cartopy v0.5.x (i.e. just before a v0.5 release), and many of the bugs mentioned here should hopefully be squashed in future releases.

Hope that helps,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top