站点数据绘制等值线:
(1)将站点数据插值为格点数据。在MeteoInfo中,有反距离权法(IDW)和cressman两个方法,其中IDW可选插值半径。
(2)griddata函数将站点数据插值为格点数据,
(3)contourfm函数创建等值线填色图层(等值线间隔和颜色可自定义)。
#Get file names
fn = 'E:/EOF/hope.txt' #数据格式经度、纬度、值
stfn='E:/EOF/st_28.csv'#数据格式Number、Name、LON 、LAT、Value_1、Value_2
#read txt
#ncol = numasciicol(fn)
#nrow = numasciirow(fn)
#a = asciiread(fn,shape=(nrow,ncol))
#lon = a[:,0]
#lat = a[:,1]
#hope = a[:,2]
#read csv
table = readtable(stfn, delimiter=',', format='%i%s%4f')
stnames = table['Name']
lat = table['LAT']
lon = table['LON']
space_1 = table['Value_1']
space_2 = table['Value_2']
#To grid data
x = arange(111, 120.5, 0.1)
y = arange(34, 41.5, 0.1)
gtemp,gx,gy = griddata((lon, lat), space_1, xi=(x, y), method='idw', radius=2.1)
#gtemp,gx,gy = griddata((lon, lat), space_2, xi=(x, y), method='idw', radius=2.1)
#Plot
axesm()
bou1_layer = shaperead('E:/EOF/city_2+26/city_2+26.shp')
mlayer = shaperead('E:/EOF/city_2+26/city_2+26.shp')
geoshow(bou1_layer, edgecolor='lightgray')
geoshow(mlayer, visible=False)
levs = [0.05, 0.10, 0.12, 0.14,0.16,0.17,0.18,0.19,0.20,0.22,0.24,0.26]
#levs = [-0.4,-0.35,-0.30, -0.25,-0.20,-0.15, -0.10,-0.05,0, 0.10, 0.20,0.25]
cols = [(255,255,255),(170,240,255),(120,230,240),(0,255,0),(127,255,0),(255,255,0),(255,215,0),(255,128,0),(255,97,0), \
(255,0,0),(176,23,31),(135,38,87),(255,0,255)]
#layer = contourfm(x, y, gtemp,20)
layer = contourfm(x, y, gtemp,levs,colors=cols)
#slayer = scatterm(lon, lat,pm,colors=['k'], size=10)
slayer = scatterm(lon, lat,space_1,levs,colors=cols, size=8)
#slayer = scatterm(lon, lat,space_2,levs,colors=cols, size=8)
slayer.addfield('Name', 'string', stnames)
slayer.addlabels('Name', fontname=u'楷体', fontsize=18, yoffset=15)
masklayer(mlayer, [layer])
xlim(111, 119.7)
ylim(34, 41.5)
title(u'第一模态',fontname=u'黑体',fontsize=20,bold=False,color='blue')
#title(u'第二模态',fontname=u'黑体',fontsize=20,bold=False,color='blue')
#text(113.3, 40.9, u'3年28城空间模态', fontname=u'黑体', fontsize=16)
colorbar(layer)