Created
December 17, 2020 19:16
-
-
Save giswqs/6342666b7b629ed0a86b79eb919a0d0c to your computer and use it in GitHub Desktop.
Velocity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "You will need to install the following packages:\n- `ipyleaflet`\n- `requests`\n- `xarray`\n- `netcdf4`\n- `geemap`" | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "from ipyleaflet import TileLayer, basemaps\nfrom ipyleaflet.velocity import Velocity\nimport xarray as xr\nimport geemap", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "center = [44.33956524809713, -130.60546875000003]\nzoom = 3\nm = geemap.Map(center=center, zoom=zoom, interpolation='nearest', basemap=basemaps.CartoDB.DarkMatter, add_google_map=False, ee_initialize=False)\nm", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "import os\n\nif not os.path.exists('wind-global.nc'):\n url = 'https://github.com/benbovy/xvelmap/raw/master/notebooks/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)", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "ds = xr.open_dataset('wind-global.nc')\nds", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "display_options = {\n 'velocityType': 'Global Wind',\n 'displayPosition': 'bottomleft',\n 'displayEmptyString': 'No wind data'\n}\nwind = Velocity(\n data=ds, \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)\nm.add_layer(wind)", | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.8.5", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"hide_input": false, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "Velocity", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
I tried to run the Velocity.ipynb script. I got an error within the second block:
center = [44.33956524809713, -130.60546875000003]
zoom = 3
m = geemap.Map(center=center, zoom=zoom, interpolation='nearest', basemap=basemaps.CartoDB.DarkMatter, add_google_map=False, ee_initialize=False)
m
I have obtained this error message:
File C:\ProgramData\anaconda3\Lib\site-packages\geemap\geemap.py:118, in Map.init(self, **kwargs)
116 if "basemap" in kwargs:
117 kwargs["basemap"] = check_basemap(kwargs["basemap"])
--> 118 if kwargs["basemap"] in basemaps.keys():
119 kwargs["basemap"] = get_basemap(kwargs["basemap"])
120 kwargs["add_google_map"] = False
TypeError: unhashable type: 'TileProvider
Is there anyone who have a solution to fix it?
Thank you for your valuable time.