{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Uncomment the following line to install [geemap](https://geemap.org) if needed.\n", "\n", "You will also need to install the following package:\n", "- `xarray`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# !pip install geemap" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import ee\n", "import geemap\n", "import geemap.colormaps as cm" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "geemap.ee_initialize()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nc_file = '../data/wind_global.nc'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "if not os.path.exists(nc_file):\n", " url = 'https://github.com/gee-community/geemap/blob/master/examples/data/wind_global.nc'\n", " import requests\n", "\n", " r = requests.get(url)\n", " wind_data = r.content\n", " with open('wind_global.nc', 'wb') as f:\n", " f.write(wind_data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test with only one variable\n", "img = geemap.netcdf_to_ee(nc_file=nc_file, var_names='u_wind')\n", "palette = cm.palettes.YlOrRd\n", "\n", "Map = geemap.Map()\n", "Map.addLayer(img, {'min': -20, 'max': 25, 'palette': palette, 'opacity': 0.6}, \"u_wind\")\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test with two variables\n", "img2 = geemap.netcdf_to_ee(nc_file=nc_file, var_names=['u_wind', 'v_wind'])\n", "Map2 = geemap.Map()\n", "Map2.addLayer(\n", " img2,\n", " {'bands': ['u_wind'], 'min': -20, 'max': 25, 'palette': palette, 'opacity': 0.6},\n", " \"uv_wind\",\n", ")\n", "Map2" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }