68 netcdf to ee
Uncomment the following line to install geemap if needed.
You will also need to install the following package:
xarray
In [ ]:
Copied!
# !pip install geemap
# !pip install geemap
In [ ]:
Copied!
import os
import ee
import geemap
import geemap.colormaps as cm
import os
import ee
import geemap
import geemap.colormaps as cm
In [ ]:
Copied!
geemap.ee_initialize()
geemap.ee_initialize()
In [ ]:
Copied!
nc_file = "../data/wind_global.nc"
nc_file = "../data/wind_global.nc"
In [ ]:
Copied!
if not os.path.exists(nc_file):
url = "https://github.com/gee-community/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)
if not os.path.exists(nc_file):
url = "https://github.com/gee-community/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)
In [ ]:
Copied!
# 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 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
In [ ]:
Copied!
# 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
# 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