|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "# Set up for JupyterLite\n", |
| 10 | + "try:\n", |
| 11 | + " import piplite\n", |
| 12 | + " await piplite.install('ipyleaflet')\n", |
| 13 | + "except ImportError:\n", |
| 14 | + " pass" |
| 15 | + ] |
| 16 | + }, |
| 17 | + { |
| 18 | + "cell_type": "code", |
| 19 | + "execution_count": null, |
| 20 | + "metadata": {}, |
| 21 | + "outputs": [], |
| 22 | + "source": [ |
| 23 | + "from random import uniform\n", |
| 24 | + "import time\n", |
| 25 | + "import ipyleaflet\n", |
| 26 | + "import json\n", |
| 27 | + "import pandas as pd\n", |
| 28 | + "from branca.colormap import linear, LinearColormap" |
| 29 | + ] |
| 30 | + }, |
| 31 | + { |
| 32 | + "cell_type": "code", |
| 33 | + "execution_count": null, |
| 34 | + "metadata": {}, |
| 35 | + "outputs": [], |
| 36 | + "source": [ |
| 37 | + "def create_random_data(length):\n", |
| 38 | + " \"Return a list of some random lat/lon/value triples.\"\n", |
| 39 | + " return [\n", |
| 40 | + " [uniform(-80, 80), uniform(-180, 180), uniform(0, 1000)] for i in range(length)\n", |
| 41 | + " ]" |
| 42 | + ] |
| 43 | + }, |
| 44 | + { |
| 45 | + "cell_type": "code", |
| 46 | + "execution_count": null, |
| 47 | + "metadata": {}, |
| 48 | + "outputs": [], |
| 49 | + "source": [ |
| 50 | + "m = ipyleaflet.Map(center=[0, 0], zoom=2)" |
| 51 | + ] |
| 52 | + }, |
| 53 | + { |
| 54 | + "cell_type": "code", |
| 55 | + "execution_count": null, |
| 56 | + "metadata": {}, |
| 57 | + "outputs": [], |
| 58 | + "source": [ |
| 59 | + "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10)\n", |
| 60 | + "m.add(heat)\n", |
| 61 | + "colormap_control = ipyleaflet.ColormapControl(\n", |
| 62 | + " caption='Intensity',\n", |
| 63 | + " colormap=heat.colormap,\n", |
| 64 | + " value_min=heat.vmin,\n", |
| 65 | + " value_max=heat.vmax,\n", |
| 66 | + " position='topright',\n", |
| 67 | + " transparent_bg=True\n", |
| 68 | + ")\n", |
| 69 | + "m.add(colormap_control)" |
| 70 | + ] |
| 71 | + } |
| 72 | + ], |
| 73 | + "metadata": { |
| 74 | + "kernelspec": { |
| 75 | + "display_name": "Python 3 (ipykernel)", |
| 76 | + "language": "python", |
| 77 | + "name": "python3" |
| 78 | + }, |
| 79 | + "language_info": { |
| 80 | + "codemirror_mode": { |
| 81 | + "name": "ipython", |
| 82 | + "version": 3 |
| 83 | + }, |
| 84 | + "file_extension": ".py", |
| 85 | + "mimetype": "text/x-python", |
| 86 | + "name": "python", |
| 87 | + "nbconvert_exporter": "python", |
| 88 | + "pygments_lexer": "ipython3", |
| 89 | + "version": "3.9.13" |
| 90 | + } |
| 91 | + }, |
| 92 | + "nbformat": 4, |
| 93 | + "nbformat_minor": 4 |
| 94 | +} |
0 commit comments