You will need to install the following packages:
ipyleaflet
requests
xarray
netcdf4
from ipyleaflet import Map, Velocity, TileLayer
import requests
import xarray as xr
import os
center = [0, 0]
zoom = 1
m = Map(center=center, zoom=zoom, interpolation='nearest')
m
tl = TileLayer(url='https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png')
m.add_layer(tl)
if not os.path.exists('wind-global.nc'):
url = 'https://github.com/benbovy/xvelmap/raw/master/notebooks/wind-global.nc'
r = requests.get(url)
wind_data = r.content
with open('wind-global.nc', 'wb') as f:
f.write(wind_data)
ds = xr.open_dataset('wind-global.nc')
display_options = {
'velocityType': 'Global Wind',
'displayPosition': 'bottomleft',
'displayEmptyString': 'No wind data'
}
wind = Velocity(data=ds, u_var='u_wind', v_var='v_wind', lat_dim='lat', lon_dim='lon', velocity_scale=0.01, max_velocity=20, display_options=display_options)
m.add_layer(wind)