【python图像】地图、地球

1.世界地图草图

 

from mpl_toolkits.basemap import Basemap
from matplotlib import pyplot as plt

map = Basemap()
map.drawcoastlines()
plt.savefig('map.png', dpi = 900)
plt.show()

 2.地球球面图

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
map = Basemap(projection='ortho', lat_0=15, lon_0=128)

#Fill the globe with a blue color 
map.drawmapboundary(fill_color='aqua')
#Fill the continents with the land color
map.fillcontinents(color='white',lake_color='blue')
map.drawcoastlines()
plt.savefig("map1.png",dpi = 900) #以dpi保存图像
plt.show()

3.经纬世界地图

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

fig=plt.figure(figsize=(20,15))#设置一个画板,将其返还给fig
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
ax.coastlines()
ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.LAND, edgecolor='black')
ax.add_feature(cfeature.LAKES, edgecolor='black')#边缘为黑色
ax.add_feature(cfeature.RIVERS)
rivers_110m = cfeature.NaturalEarthFeature('physical', 'rivers_lake_centerlines', '110m')
ax.add_feature(rivers_110m, facecolor='None', edgecolor='b')

#添加网格线,true
ax.gridlines(draw_labels=True, xlocs=[-179, -90, 0, 90,179])

#以dpi保存图像
plt.savefig("map2.png",dpi = 900)
plt.show()

你可能感兴趣的:(数据分析和混沌理论,python,开发语言,matplotlib)