{ "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/giswqs/geemap/blob/master/examples/data/wind-global.nc'\n", " import requests\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(img2, {'bands':['u_wind'],'min':-20, 'max':25, 'palette':palette, 'opacity':0.6}, \"uv_wind\")\n", "Map2" ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }