【发布时间】:2020-06-25 15:29:12
【问题描述】:
我想绘制一个类似于以下示例的形状(来自 Naval Research Laboratory TC 页面)。形状由 4 个半径定义,每个象限一个。
我在经纬度坐标中有多个轨迹中心,我使用 Basemap 绘制这些轨迹中心:
def m_plot_wind_speeds(x,y, mps):
# There's a switch-like statement here to determine the color of the
# line based on wind speed which I ignored. This is passed to the
# color kwarg in m.plot as cur_color.
m.plot(x,y, '.-', markersize=ms, linewidth=lw, color=cur_color, \
mew=1.5, markerfacecolor='k')
m = Basemap(projection='cyl',area_thresh=1000, \
llcrnrlat=southLat,urcrnrlat=northLat,llcrnrlon=westLong,urcrnrlon=eastLong,resolution='h')
parallels = np.arange(southLat,northLat+10,10.) # make latitude lines ever 5 degrees from 30N-50N
meridians = np.arange(westLong,eastLong+30,30.) # make longitude lines every 5 degrees from 95W to 70W
m.drawparallels(parallels,labels=[1,0,0,0],labelstyle="+/-", linewidth=0, fontsize=6)
m.drawmeridians(meridians,labels=[0,0,0,1],labelstyle="+/-", linewidth=0, fontsize=6)
m.drawcountries(linewidth=0.25)
m.bluemarble()
# data is a [10]x[~]x[10] list. There are 10 trajectories, each with
# varying lengths. Each trajectory has 10 attributes.
for traj in data:
lat = []
lon = []
wind_speed=[]
for i in traj:
lat.append(float(i[1]))
lon.append(float(i[0]))
wind_speed.append(float(i[2]))
for j,var in enumerate(traj):
if j > 0:
x,y = m([lon[j], lon[j-1]], [lat[j], lat[j-1]])
else:
x,y = m([lon[j], lon[j]],[lat[j], lat[j]])
m_plot_wind_speeds(x,y,wind_speed[j])
# TODO: Insert a function here that takes in a 4 radii and plots them
# in each quadrant.
【问题讨论】:
标签: matplotlib geometry matplotlib-basemap cartopy metpy