2012-12-01 120 views
2

我想绘制用cartopy生成的地图上的轮廓。如果我运行这个例子:使用最新的代码的检出从GitHub轮廓与cartopy:ValueError:无效的变换:不支持球形轮廓

http://scitools.org.uk/cartopy/docs/latest/matplotlib/introductory_examples/03.contours.html

我得到:

ValueError: invalid transform: Spherical contouring is not supported - 
consider using PlateCarree/RotatedPole. 

一个应该怎么做呢?

(问到原始通告http://matplotlib.1069221.n5.nabble.com/ANN-Cartopy-A-new-mapping-library-using-matplotlib-td39886.html的响应)

回答

2

http://scitools.org.uk/cartopy/docs/latest/matplotlib/introductory_examples下在cartopy文档提供的实施例过时相比代码库。有一张开发票来更新所有示例(https://github.com/SciTools/cartopy/issues/128)。

在这种情况下,只需用

plt.contourf(lons, lats, data, transform=ccrs.PlateCarree()) 

更换线

plt.contourf(lons, lats, data, transform=ccrs.Geodetic()) 

和例子应该重新工作。

matplotlib/cartopy introductory section of the cartopy docs具有 具有轮廓例子可能感兴趣http://scitools.org.uk/cartopy/docs/latest/matplotlib/advanced_plotting.html#contour-plots 所得图像:

output from linked example

HTH,