|
76 | 76 | "import numpy as np\n",
|
77 | 77 | "import matplotlib.lines\n",
|
78 | 78 | "import matplotlib.pyplot as plt\n",
|
| 79 | + "# autoreload\n", |
| 80 | + "%load_ext autoreload\n", |
| 81 | + "%autoreload 2\n", |
79 | 82 | "%matplotlib inline"
|
80 | 83 | ]
|
81 | 84 | },
|
|
124 | 127 | "results = []\n",
|
125 | 128 | "SRwidgets = ipysliderule.widgets()\n",
|
126 | 129 | "points_dropdown = None\n",
|
| 130 | + "update_button = widgets.Button(description=\"Update Map\")\n", |
127 | 131 | "run_button = widgets.Button(description=\"Run SlideRule!\")\n",
|
128 | 132 | "run_output = widgets.Output()\n",
|
129 | 133 | "refresh_button = widgets.Button(description=\"Refresh Plot\")\n",
|
|
151 | 155 | "outputs": [],
|
152 | 156 | "source": [
|
153 | 157 | "# create ipyleaflet map in specified projection\n",
|
154 |
| - "m = ipysliderule.leaflet('Global', layer_control=False)\n", |
| 158 | + "m = ipysliderule.leaflet(SRwidgets.projection.value)\n", |
| 159 | + "# install click handler callback\n", |
| 160 | + "m.add_selected_callback(SRwidgets.atl06_click_handler)\n", |
155 | 161 | "display(m.map)\n",
|
156 | 162 | "display(run_output)"
|
157 | 163 | ]
|
158 | 164 | },
|
| 165 | + { |
| 166 | + "cell_type": "code", |
| 167 | + "execution_count": null, |
| 168 | + "metadata": { |
| 169 | + "extensions": { |
| 170 | + "jupyter_dashboards": { |
| 171 | + "version": 1, |
| 172 | + "views": { |
| 173 | + "default_view": { |
| 174 | + "hidden": true |
| 175 | + } |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + }, |
| 180 | + "outputs": [], |
| 181 | + "source": [ |
| 182 | + "# update map\n", |
| 183 | + "def on_update_clicked(b):\n", |
| 184 | + " m.add_layer(\n", |
| 185 | + " layers=SRwidgets.layers.value,\n", |
| 186 | + " rendering_rule=SRwidgets.rendering_rule\n", |
| 187 | + " )\n", |
| 188 | + " \n", |
| 189 | + "# map widgets\n", |
| 190 | + "display(widgets.VBox([\n", |
| 191 | + " SRwidgets.projection,\n", |
| 192 | + " SRwidgets.layers,\n", |
| 193 | + " SRwidgets.raster_functions\n", |
| 194 | + "]))\n", |
| 195 | + "\n", |
| 196 | + "# update button\n", |
| 197 | + "update_button.on_click(on_update_clicked)\n", |
| 198 | + "display(update_button)" |
| 199 | + ] |
| 200 | + }, |
159 | 201 | {
|
160 | 202 | "cell_type": "code",
|
161 | 203 | "execution_count": null,
|
|
251 | 293 | "def on_refresh_clicked(b):\n",
|
252 | 294 | " global atl06_rsps\n",
|
253 | 295 | " with refresh_output:\n",
|
254 |
| - " if atl06_rsps.shape[0] > 0:\n", |
| 296 | + " if atl06_rsps and atl06_rsps.shape[0] > 0:\n", |
255 | 297 | " max_plot_points = 10000\n",
|
256 | 298 | " if points_dropdown.value == \"100K\":\n",
|
257 | 299 | " max_plot_points = 100000\n",
|
258 | 300 | " elif points_dropdown.value == \"unlimited\":\n",
|
259 | 301 | " max_plot_points = 1000000000\n",
|
260 | 302 | " m.GeoData(atl06_rsps, column_name=SRwidgets.variable.value, cmap=SRwidgets.colormap, max_plot_points=max_plot_points)\n",
|
261 |
| - " \n", |
| 303 | + "\n", |
262 | 304 | "# link buttons\n",
|
263 | 305 | "run_button.on_click(on_run_clicked)\n",
|
264 | 306 | "refresh_button.on_click(on_refresh_clicked)"
|
|
316 | 358 | " SRwidgets.variable,\n",
|
317 | 359 | " SRwidgets.cmap,\n",
|
318 | 360 | " points_dropdown,\n",
|
319 |
| - " SRwidgets.reverse\n", |
| 361 | + " SRwidgets.reverse,\n", |
320 | 362 | "]))\n",
|
321 | 363 | "\n",
|
322 | 364 | "# display buttons\n",
|
|
518 | 560 | "display(pc_button)\n",
|
519 | 561 | "display(pc_output)"
|
520 | 562 | ]
|
| 563 | + }, |
| 564 | + { |
| 565 | + "cell_type": "code", |
| 566 | + "execution_count": null, |
| 567 | + "metadata": {}, |
| 568 | + "outputs": [], |
| 569 | + "source": [] |
521 | 570 | }
|
522 | 571 | ],
|
523 | 572 | "metadata": {
|
|
0 commit comments