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