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

问题描述 投票:1回答:1

我正在尝试使用Cartopy的Proejction NearsidePerspective,但是与Matplotlib提供的真实地球图像重叠,并通过降低satellite_height参数进行缩放。对于此特定类型的设置,Cartopy似乎无法正确修剪图像。图像显示仍然是人们期望的地图边界。

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 matplotlib map-projections cartopy
1个回答
2
投票

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

result of the OP's code

这可能是版本问题,也可能是Jupyter Notebook。

© www.soinside.com 2019 - 2024. All rights reserved.