使用Cartopy重投影图像的困难

3

我在使用Cartopy重新投影图像时遇到了问题。

我有以下代码(修改自这里的示例):

import os
import matplotlib.pyplot as plt

from cartopy import config
import cartopy.crs as ccrs
import cartopy.feature as cfeature

fig = plt.figure(figsize=(8, 10))

img_extent = (-120.67660000000001, -106.32104523100001, 13.2301484511245, 30.766899999999502)
img = plt.imread('/tmp/Miriam.A2012270.2050.2km.jpg')

ax = plt.axes(projection=ccrs.PlateCarree())
plt.title('Hurricane Miriam from the Aqua/MODIS satellite\n'
          '2012 09/26/2012 20:50 UTC')

ax.set_extent([-125, -105, 10, 35], ccrs.Geodetic())

ax.imshow(img, origin='upper', extent=img_extent, transform=ccrs.PlateCarree())
ax.coastlines(resolution='50m', color='black', linewidth=1)
ax.gridlines()

plt.show()

它将生成以下图片 PlateCarree

然而,当我尝试选择不同的投影方式(比如Lambert Conformal),用替换方法来改变原有代码

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

使用

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

我得到了以下图片:

LambertConformal

正如你所看到的,这张图片存在问题。我做错了什么?是否可以在不同的投影方式下显示此图片?


我在我的0.9版本上无法复制它,即使更改投影后图像也不会显示。如果您有一个1层栅格,则可以考虑使用pcolormesh作为替代方案。 - Rutger Kassies
2个回答

10
未来参考,这个问题是由于cartopy中的一个错误引起的,该错误已在主分支上得到修复。修复将包含在0.10.0版本中。使用修复代码运行Julien脚本的输出如下所示:

enter image description here


1
这绝对是一个bug,我建议你打开一个github问题(https://github.com/SciTools/cartopy/issues/new)。 我最初认为可能是LambertConformal投影,但其他投影也存在同样的问题(例如Robinson),这表明图像范围的定义存在问题。 不幸的是,目前我没有解决方法。 希望这有所帮助。

谢谢@pelson,我已经提交了一个错误报告。请让我知道我如何帮忙。 - Julien Chastang

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接