gpt4 book ai didi

python - 如何将 Matplotlib 的 stock_img() 与 Cartopy 的 NearsidePerspective 投影相匹配

转载 作者:行者123 更新时间:2023-12-01 01:05:39 24 4
gpt4 key购买 nike

我正在尝试使用Cartopy的投影NearsidePerspective,但与Matplotlib提供的真实地球图像重叠,并通过降低satellite_height参数来放大一点。 Cartopy 似乎无法针对这种特定类型的设置正确修剪图像。图像的显示仍然超出了人们所期望的 map 边界。

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

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

# Set Projection
height=3000000
#height=35785831 # this is the default height
projection=ccrs.NearsidePerspective(central_longitude=120,
central_latitude=78,
satellite_height=height)
# Draw
ax = plt.axes(projection=projection)
ax.stock_img()
ax.coastlines(resolution='50m')
plt.show()

enter image description here

如何将 Matplotlib 的 stock_img() 和 NearsidePerspective 的此配置结合起来才能正常工作?或者有什么替代方法可以获得所需的结果?

我在 Jupyter Notebook、Matplotlib 3.0.2 和 Cartopy 0.16.0 上使用 Python 3.6。

最佳答案

在装有 Python 3.7、Matplotlib 3.0.3 和 Cartopy 0.17.0 的 Mac 上使用相同的代码,图像被正确裁剪:

result of the OP's code

这可能是版本问题或 Jupyter Notebook 的问题。

关于python - 如何将 Matplotlib 的 stock_img() 与 Cartopy 的 NearsidePerspective 投影相匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55395163/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com