当前位置:   article > 正文

Python绘图,填色图叠加青藏高原边界,需要青藏高原shape文件_青藏高原shp文件

青藏高原shp文件
from scipy.io import loadmat
import numpy as np
address = 'G:/work2022/python/SCF_month_1966-2018_observation/'
matfn = address + '01.mat'#读取mat文件名
data = loadmat(matfn)
w1 = data['scf']

matfn = address + '02.mat'#读取mat文件名
data = loadmat(matfn)
w2 = data['scf']

matfn = address + '12.mat'#读取mat文件名
data = loadmat(matfn)
w3 = data['scf']
w = np.zeros((360,1440,26,3))
w[0:360,0:1440,0:26,0]=w1[0:360,0:1440,14:40]
w[0:360,0:1440,0:26,1]=w2[0:360,0:1440,14:40]
w[0:360,0:1440,0:26,2]=w3[0:360,0:1440,13:39]
wmean=np.nanmean(w,axis=3)
wm=np.nanmean(wmean,axis=2)

## 绘图
lon=np.arange(0.125-180,180,0.25)
lat=np.arange(90-0.125,0,-0.25)
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter
from cartopy.io.shapereader import Reader
Alberts_China = ccrs.AlbersEqualArea(central_longitude=105,
                            standard_parallels=(25.0, 47.0)) 
# 1
fig = plt.figure()
proj = ccrs.PlateCarree(central_longitude=0)
extents = [65, 105, 25, 40]
ax = plt.subplot(111, projection=proj)
ax.set_extent(extents, crs=proj)
ax.set_xticks(np.arange(65, 106, 10), crs=proj)
ax.set_yticks(np.arange(25, 45, 5), crs=proj)
ax.xaxis.set_major_formatter(LongitudeFormatter())
ax.yaxis.set_major_formatter(LatitudeFormatter())
reader    = Reader('G:/work2022/python/SCF_month_1966-2018_observation/TPBoundary_new(2021).shp')
ax.add_geometries(reader.geometries(),
                   crs=ccrs.PlateCarree(), # 坐标系需要对应,不然可能会出现坐标不对应的情况哦
                   edgecolor='r',
                   linewidths=2,facecolor='none') 
c2 = ax.contourf(lon,lat,wm, levels=np.arange(0,1.1,0.1),
            cmap=plt.cm.jet,zorder=0)
cbar = fig.colorbar(c2, orientation='horizontal', 
                    fraction=0.5, pad=0.12, aspect=20, shrink=0.65)
cbar.set_ticks([0,0.2,0.4,0.6,0.8,1.0])
cbar.set_label('SCF') 
ax.set_title('(a) Winter',loc='left')
cbar.set_label('SCF',fontsize=15) 
ax.set_title('(a)Winter',loc='left',fontsize=15)
# 设置刻度字体大小
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
cbar.ax.tick_params(labelsize=15) 
plt.show();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/612634
推荐阅读
相关标签
  

闽ICP备14008679号