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()

生成以下图像板卡瑞

但是,当我尝试选择不同的投影时,比如 Lambert Conformal,通过替换

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

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

我得到以下图像:

兰伯特保形

如您所见,此图像有问题。我究竟做错了什么?是否可以在不同的投影中显示此图像?

4

2 回答 2

10

供将来参考,此问题是由于 cartopy 中的一个错误,该错误现已在 master 分支上修复。该修复将包含在 0.10.0 版本中。使用固定代码运行的 Julien 脚本的输出如下所示:

在此处输入图像描述

于 2013-12-09T14:12:47.263 回答
1

这绝对是一个错误,所以我鼓励你打开一个 github 问题(https://github.com/SciTools/cartopy/issues/new)。

我最初认为它可能是 LambertConformal 投影,但同样的问题也出现在其他投影中(例如 Robinson),这表明图像范围的定义存在问题。

不幸的是,我目前没有解决方法。

高温高压

于 2013-10-03T09:05:56.227 回答