暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Python气象数据处理与绘图:Cartopy绘制不同投影的地图

气海无涯 2021-08-19
2653

1、导入模块

1import numpy as np
2import matplotlib.pyplot as plt
3import cartopy.crs as ccrs
4import cartopy.io.shapereader as shpreader
5import cartopy.feature as cfeat
6import shapely.geometry as sgeom
7import shapefile

2、加载矢量数据

1world = shpreader.Reader('/home/kesci/work/map/world.shp')

3、绘图

(1)PlateCarree
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(2)AlbersEqualArea
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.AlbersEqualArea(central_longitude=110))
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(3)AzimuthalEquidistant
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.AzimuthalEquidistant())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(4)EquidistantConic
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.EquidistantConic())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(5)LambertConformal
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertConformal())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(6)LambertCylindrical
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertCylindrical())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(7)Miller
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Miller())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(8)Mollweide
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Mollweide())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(9)Orthographic
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Orthographic(central_longitude=110))
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(10)Robinson
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Robinson(central_longitude=150))
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(11)Sinusoidal
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Sinusoidal(central_longitude=150))
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(12)Stereographic
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Stereographic())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(13)TransverseMercator
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.TransverseMercator())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(14)InterruptedGoodeHomolosine
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.InterruptedGoodeHomolosine())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(15)RotatedPole
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.RotatedPole())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(16)Geostationary
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.Geostationary())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(17)EckertI
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.EckertI())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(18)EqualEarth
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.EqualEarth())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(19)LambertAzimuthalEqualArea
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.LambertAzimuthalEqualArea())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()

(20)SouthPolarStereo
1fig = plt.figure(figsize=(15, 15))
2ax = fig.add_subplot(1, 1, 1, projection=ccrs.SouthPolarStereo())
3ax.set_global()
4ax.add_geometries(world.geometries(), crs=ccrs.PlateCarree(), linewidths=1.5,edgecolor='k',facecolor='none')
5plt.show()



有问题可以到QQ群里进行讨论,我们在那边等大家。

QQ群号:854684131

文章转载自气海无涯,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论