importnumpyasnpfromgeographiclib.geodesicimportGeodesicangles=[90]foriinrange(len(df)-1):info=Geodesic.WGS84.Inverse(df.iloc[i,1],df.iloc[i,0],df.iloc[i+1,1],df.iloc[i+1,0])angles.append(info['azi2'])# Change from CW-from-North to CCW-from-East.angles=np.deg2rad(450-np.array(angles))# Normalize the speed to use as the length of the arrows.r=df['Speed']/df['Speed'].max()df['u']=r*np.cos(angles)df['v']=r*np.sin(angles)

In [6]:

importmplleafletimportmatplotlib.pyplotaspltfig,ax=plt.subplots()df=df.dropna()# This style was lost below.ax.plot(df['Longitude'],df['Latitude'],color='darkorange',linewidth=5,alpha=0.5)# This is preserved in the SVG icon.sub=10kw={'color':'deepskyblue','alpha':0.8,'scale':10}ax.quiver(df['Longitude'][::sub],df['Latitude'][::sub],df['u'][::sub],df['v'][::sub],**kw)gj=mplleaflet.fig_to_geojson(fig=fig)

In [7]:

importfoliumlon,lat=-38.51386097,-13.00868051zoom_start=14m=folium.Map(location=[lat,lon],tiles='Cartodb Positron',zoom_start=zoom_start)# The first geometry is a lineString.line_string=gj['features'][0]gjson=folium.features.GeoJson(line_string)m.add_child(gjson)m.save(os.path.join('results','Folium_and_mplleaflet_0.html'))m