I'd like to plot contours over a map produced with cartopy. If I run the example at:
http://scitools.org.uk/cartopy/docs/latest/matplotlib/introductory_examples/03.contours.html
using a checkout of the latest code from github I get:
ValueError: invalid transform: Spherical contouring is not supported -
consider using PlateCarree/RotatedPole.
How should one do this?
(asked as a response to the original announcement http://matplotlib.1069221.n5.nabble.com/ANN-Cartopy-A-new-mapping-library-using-matplotlib-td39886.html )
The examples provided in the cartopy docs under http://scitools.org.uk/cartopy/docs/latest/matplotlib/introductory_examples
are out of date compared to the codebase. There is a development ticket to update all of the examples ( https://github.com/SciTools/cartopy/issues/128 ).
In this case, simply replace the line
plt.contourf(lons, lats, data, transform=ccrs.Geodetic())
with
plt.contourf(lons, lats, data, transform=ccrs.PlateCarree())
and the example should work again.
The matplotlib/cartopy introductory section of the cartopy docs has has a contouring example which may be of interest http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting.html#contour-plots The resulting image:
HTH,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.