我已使用tripcolor绘制了图像,并且我希望背景为具有缩放功能的google地图,其中显示区域,州和我的绘图图像位于google地图的前面。
我尝试过Cartopy,但只有google map即将推出,而不是情节。
# This plot is for .mat file extension plot .
import matplotlib.pyplot as plt
from scipy.io import loadmat
import datetime
import pandas as pd
from dateutil.parser import parse
import numpy as np
from datetime import timedelta
import matplotlib.tri as mtri
datamat = loadmat('IOEC_ECM2017_BC.mat')
Xp = datamat['Xp']
Yp = datamat['Yp']
strt = datetime.datetime(2017, 1, 11, 0, 0)
end = datetime.datetime(2017, 1, 21, 0, 0)
numdays = 3
def perdelta(strt, end, delta):
curr = strt
while curr < end:
yield curr
curr += delta
tri_new = pd.read_csv('fort.ele', delim_whitespace=True, names=('A', 'B',
'C', 'D'), usecols=[1, 2, 3], skiprows=1,
dtype={'D': np.int})
dateList = []
for result in perdelta(strt, strt + timedelta(days=2),
timedelta(hours=3)):
# timedelta days will run this loop for startdate and end date .
# timedelta hours will do interval time , here 3 hourly interval .
dat = result
# print(result)
dt = parse(str(dat))
yr = dt.year
mn = dt.month
d = dt.day
hr = dt.hour
mi = dt.minute
print(yr,mn,d,hr,mi)
if hr < 10:
# d='0'+str(d)
hr = '0' + str(hr)
else:
d = str(d)
hr = str(hr)
if int(d) < 10 :
d='0'+str(d)
else:
d=str(d)
varname = 'Hsig_' + str(yr) + '0' + str(mn) + str(d) + '_' + hr + '0000'
print("v:",varname)
x = Xp.flatten()
y = Yp.flatten()
z = datamat[varname]
z1 = z.flatten()
tri_sub = tri_new.apply(lambda x: x - 1)
triang = mtri.Triangulation(x, y, triangles=tri_sub)
pp = plt.tripcolor(triang, z1, cmap='jet', vmin=0.0, vmax="0.5")
#gmap.plot(x,y,cmap="jet",vmin=0.0,vmax="0.5")
plt.colorbar(pp)
plt.show()
我希望在这个纬度和经度范围内,我的背景图像是显示状态的google地图,具有缩放功能,并且绘图结果与该google map重叠。作为示例,您可以看到我将绘图图像放在了该位置只需要背景作为具有缩放功能的Google地图。