Skip to content

Instantly share code, notes, and snippets.

@deeplook
Created April 19, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeplook/f935cd70cef356ba4517645ca0fd70ce to your computer and use it in GitHub Desktop.
Save deeplook/f935cd70cef356ba4517645ca0fd70ce to your computer and use it in GitHub Desktop.
COVID-19 travel restictions example remake im 10 lines of code.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# COVID-19 Travel Restrictions (2020-04-18)\n",
"\n",
"- https://twitter.com/heredev/status/1251172326860820488\n",
"- https://app.developer.here.com/covid19-travel-restrictions/\n",
"\n",
"Here with data only for Europe and no popups..."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "90b3eed3579c4609a0d314951b75e6d3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(center=[57, 30], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_tex…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# https://app.developer.here.com/covid19-travel-restrictions/\n",
"import ipyleaflet, requests\n",
"colors = (\"red\", \"blue\", \"green\") # closed borders, restricted borders, suspended flights\n",
"names = ([\"Belgium\", \"Bosnia and Herzegovina\", \"Bulgaria\", \"Croatia\", \"Czech Republic\", \"Denmark\", \"Finland\", \"Greece\", \"Hungary\", \"Latvia\", \"Lithuania\", \"Macedonia\", \"Norway\", \"Poland\", \"Russia\", \"Republic of Serbia\", \"Spain\", \"Switzerland\", \"Ukraine\"], [\"Albania\", \"Austria\", \"France\", \"Germany\", \"Italy\", \"Netherlands\", \"Luxembourg\", \"Portugal\"], [\"Turkey\", \"Romania\", \"Slovakia\", \"Sweden\"])\n",
"data = requests.get(\"https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json\").json()\n",
"features = list({\"type\": \"FeatureCollection\", \"features\": [f for f in data[\"features\"] if f[\"properties\"][\"name\"] in cat]} for cat in names)\n",
"styles = ({\"color\": col, \"opacity\": 0.3, \"fillOpacity\": 0.1} for col in colors)\n",
"m = ipyleaflet.Map(center=[57, 30], zoom=3)\n",
"for feats, style in zip(features, styles): m += ipyleaflet.GeoJSON(data=feats, style=style)\n",
"m"
]
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment