简体   繁体   中英

How to fit Matplotlib's stock_img() with Cartopy's NearsidePerspective projection

I am trying to use Cartopy's proejction NearsidePerspective, but overlaping with the real Earth image provided by Matplotlib, and zooming in a bit by lowering the satellite_height parameter. It appears that Cartopy is not able to trim the image properly for this specific type of setting. The image is displayed still oustide of what one would expect to be the map boundaries.

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

在此处输入图片说明

How can I combine Matplotlib's stock_img() and this configuration of NearsidePerspective to work properly? Or what would be an alternative way to get the result desired?

I am using Python 3.6 on Jupyter Notebook, Matplotlib 3.0.2, and Cartopy 0.16.0.

Using the same code on a mac with Python 3.7, Matplotlib 3.0.3, and Cartopy 0.17.0, the image is cropped correctly:

OP代码的结果

This may either be a version problem or with Jupyter Notebook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM