generated from opengeos/solara-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
167 additions
and
11 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import leafmap\n", | ||
"import solara\n", | ||
"from fire import *" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"run()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"zoom = solara.reactive(14)\n", | ||
"center = solara.reactive((34, -116))\n", | ||
"\n", | ||
"before_url = \"https://huggingface.co/datasets/cboettig/solara-data/resolve/main/before.tif\"\n", | ||
"after_url = \"https://huggingface.co/datasets/cboettig/solara-data/resolve/main/after.tif\"\n", | ||
"\n", | ||
"style = {\n", | ||
" \"stroke\": False,\n", | ||
" \"fill\": True,\n", | ||
" \"fillColor\": \"#ff6666\",\n", | ||
" \"fillOpacity\": 0.5,\n", | ||
"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 11, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"class Map(leafmap.Map):\n", | ||
" def __init__(self, **kwargs):\n", | ||
" super().__init__(**kwargs)\n", | ||
" # Add what you want below\n", | ||
" # self.add_gdf(jtree, layer_name = \"Joshua Tree NP\")\n", | ||
" self.add_gdf(jtree_fires, layer_name = \"All Fires\", style=style)\n", | ||
" self.add_gdf(big, layer_name = big.FIRE_NAME.item())\n", | ||
" #self.add_raster(\"before.tif\", layer_name = \"before\", colormap=\"viridis\")\n", | ||
" #self.add_raster(\"after.tif\", layer_name = \"after\", colormap=\"viridis\")\n", | ||
" self.split_map(before_url, after_url, \n", | ||
" left_label= \"before fire\", \n", | ||
" right_label = \"after fire\")\n", | ||
" #self.add_stac_gui()\n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"@solara.component\n", | ||
"def Page():\n", | ||
" with solara.Column(style={\"min-width\": \"500px\"}):\n", | ||
" # solara components support reactive variables\n", | ||
" # solara.SliderInt(label=\"Zoom level\", value=zoom, min=1, max=20)\n", | ||
" # using 3rd party widget library require wiring up the events manually\n", | ||
" # using zoom.value and zoom.set\n", | ||
" Map.element( # type: ignore\n", | ||
" zoom=zoom.value,\n", | ||
" on_zoom=zoom.set,\n", | ||
" center=center.value,\n", | ||
" on_center=center.set,\n", | ||
" scroll_wheel_zoom=True,\n", | ||
" toolbar_ctrl=False,\n", | ||
" data_ctrl=False,\n", | ||
" height=\"780px\",\n", | ||
" )\n", | ||
" solara.Text(f\"Zoom: {zoom.value}\")\n", | ||
" solara.Text(f\"Center: {center.value}\")\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "40a3f4affe8749f6882c35fe09663017", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/html": [ | ||
"Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)." | ||
], | ||
"text/plain": [ | ||
"Cannot show ipywidgets in text" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"Page()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": ".venv", | ||
"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.11.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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