Uncomment the following line to install geemap if needed.
You will also need to install the following package:
xarray
# !pip install geemap
import os
import ee
import geemap
import geemap.colormaps as cm
geemap.ee_initialize()
nc_file = '../data/wind-global.nc'
if not os.path.exists(nc_file):
url = 'https://github.com/giswqs/geemap/blob/master/examples/data/wind-global.nc'
import requests
r = requests.get(url)
wind_data = r.content
with open('wind-global.nc', 'wb') as f:
f.write(wind_data)
# Test with only one variable
img = geemap.netcdf_to_ee(nc_file=nc_file, var_names='u_wind')
palette=cm.palettes.YlOrRd
Map = geemap.Map()
Map.addLayer(img, {'min':-20, 'max':25, 'palette':palette, 'opacity':0.6}, "u_wind")
Map
# Test with two variables
img2 = geemap.netcdf_to_ee(nc_file=nc_file, var_names=['u_wind','v_wind'])
Map2 = geemap.Map()
Map2.addLayer(img2, {'bands':['u_wind'],'min':-20, 'max':25, 'palette':palette, 'opacity':0.6}, "uv_wind")
Map2