{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geemap\n", "import os\n", "import xarray as xr\n", "from ipyleaflet import Map, Velocity, TileLayer, basemaps" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "Map = geemap.Map(center=[44.33, -130.60], zoom=3, interpolation='nearest')\n", "Map.add_layer(basemaps.CartoDB.DarkMatter)\n", "Map" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "file_path = os.path.abspath('../data/wind-global.nc')\n", "if not os.path.exists(file_path):\n", " url = 'https://github.com/giswqs/geemap/raw/master/examples/data/wind-global.nc'\n", " import requests\n", " r = requests.get(url)\n", " wind_data = r.content\n", " with open(file_path, 'wb') as f:\n", " f.write(wind_data)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = xr.open_dataset(file_path)\n", "ds" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "display_options = {\n", " 'velocityType': 'Global Wind',\n", " 'displayPosition': 'bottomleft',\n", " 'displayEmptyString': 'No wind data'\n", "}\n", "wind = Velocity(\n", " data=ds, \n", " name = 'Velocity',\n", " zonal_speed='u_wind', meridional_speed='v_wind', \n", " latitude_dimension='lat', longitude_dimension='lon', \n", " velocity_scale=0.01, max_velocity=20, \n", " display_options=display_options\n", ")\n", "Map.add_layer(wind)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "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.2" } }, "nbformat": 4, "nbformat_minor": 4 }