Spaces:
Running
Running
Added geemap example
Browse files- README.md +2 -1
- pages/00_home.py +2 -1
- pages/01_leafmap.py +0 -4
- pages/02_geemap.py +52 -22
- pages/03_mapbox.py +1 -4
- pages/04_cesium.py +1 -4
- pages/05_maplibre.py +1 -4
- pages/06_openlayers.py +1 -4
- pages/07_ipyleaflet.py +44 -0
README.md
CHANGED
@@ -16,7 +16,8 @@ A collection of [Solara](https://github.com/widgetti/solara) web apps for geospa
|
|
16 |
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future.
|
17 |
|
18 |
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
19 |
-
-
|
|
|
20 |
|
21 |
## Demos
|
22 |
|
|
|
16 |
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future.
|
17 |
|
18 |
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
19 |
+
- GitHub: <https://github.com/opengeos/solara-geospatial>
|
20 |
+
- Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
|
21 |
|
22 |
## Demos
|
23 |
|
pages/00_home.py
CHANGED
@@ -13,7 +13,8 @@ def Page():
|
|
13 |
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future. Click on the menu above to see the other pages.
|
14 |
|
15 |
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
16 |
-
-
|
|
|
17 |
|
18 |
### Demos
|
19 |
|
|
|
13 |
Just a proof-of-concept for now. Not all features are working yet. More features will be added in the future. Click on the menu above to see the other pages.
|
14 |
|
15 |
- Web App: <https://giswqs-solara-geospatial.hf.space>
|
16 |
+
- GitHub: <https://github.com/opengeos/solara-geospatial>
|
17 |
+
- Hugging Face: <https://huggingface.co/spaces/giswqs/solara-geospatial>
|
18 |
|
19 |
### Demos
|
20 |
|
pages/01_leafmap.py
CHANGED
@@ -1,7 +1,3 @@
|
|
1 |
-
"""
|
2 |
-
# ipyleaflet
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import leafmap
|
6 |
import solara
|
7 |
from leafmap.toolbar import change_basemap
|
|
|
|
|
|
|
|
|
|
|
1 |
import leafmap
|
2 |
import solara
|
3 |
from leafmap.toolbar import change_basemap
|
pages/02_geemap.py
CHANGED
@@ -1,30 +1,60 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import geemap
|
6 |
|
7 |
import solara
|
8 |
|
9 |
-
zoom = solara.reactive(
|
10 |
-
center = solara.reactive([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
|
13 |
@solara.component
|
14 |
def Page():
|
15 |
-
solara.
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
1 |
+
|
2 |
+
import ee
|
|
|
|
|
3 |
import geemap
|
4 |
|
5 |
import solara
|
6 |
|
7 |
+
zoom = solara.reactive(4)
|
8 |
+
center = solara.reactive([40, -100])
|
9 |
+
|
10 |
+
|
11 |
+
class Map(geemap.Map):
|
12 |
+
def __init__(self, **kwargs):
|
13 |
+
super().__init__(**kwargs)
|
14 |
+
self.add_ee_data()
|
15 |
+
|
16 |
+
|
17 |
+
def add_ee_data(self):
|
18 |
+
|
19 |
+
# Add Earth Engine dataset
|
20 |
+
dem = ee.Image('USGS/SRTMGL1_003')
|
21 |
+
landsat7 = ee.Image('LANDSAT/LE7_TOA_5YEAR/1999_2003').select(
|
22 |
+
['B1', 'B2', 'B3', 'B4', 'B5', 'B7']
|
23 |
+
)
|
24 |
+
states = ee.FeatureCollection("TIGER/2018/States")
|
25 |
+
|
26 |
+
# Set visualization parameters.
|
27 |
+
vis_params = {
|
28 |
+
'min': 0,
|
29 |
+
'max': 4000,
|
30 |
+
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
|
31 |
+
}
|
32 |
+
|
33 |
+
# Add Earth Engine layers to Map
|
34 |
+
self.addLayer(dem, vis_params, 'SRTM DEM', True, 0.5)
|
35 |
+
self.addLayer(
|
36 |
+
landsat7,
|
37 |
+
{'bands': ['B4', 'B3', 'B2'], 'min': 20, 'max': 200, 'gamma': 2.0},
|
38 |
+
'Landsat 7',
|
39 |
+
)
|
40 |
+
self.addLayer(states, {}, "US States")
|
41 |
|
42 |
|
43 |
@solara.component
|
44 |
def Page():
|
45 |
+
with solara.Column(style={"min-width": "500px"}):
|
46 |
+
# solara components support reactive variables
|
47 |
+
solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
|
48 |
+
# using 3rd party widget library require wiring up the events manually
|
49 |
+
# using zoom.value and zoom.set
|
50 |
+
Map.element( # type: ignore
|
51 |
+
zoom=zoom.value,
|
52 |
+
on_zoom=zoom.set,
|
53 |
+
center=center.value,
|
54 |
+
on_center=center.set,
|
55 |
+
scroll_wheel_zoom=True,
|
56 |
+
add_google_map=True,
|
57 |
+
|
58 |
+
)
|
59 |
+
solara.Text(f"Zoom: {zoom.value}")
|
60 |
+
solara.Text(f"Center: {center.value}")
|
pages/03_mapbox.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1 |
-
|
2 |
-
# ipyleaflet
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import mapwidget.mapbox as mapwidget
|
6 |
|
7 |
import solara
|
|
|
1 |
+
|
|
|
|
|
|
|
2 |
import mapwidget.mapbox as mapwidget
|
3 |
|
4 |
import solara
|
pages/04_cesium.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1 |
-
|
2 |
-
# ipyleaflet
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import os
|
6 |
import mapwidget.cesium as mapwidget
|
7 |
|
|
|
1 |
+
|
|
|
|
|
|
|
2 |
import os
|
3 |
import mapwidget.cesium as mapwidget
|
4 |
|
pages/05_maplibre.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1 |
-
|
2 |
-
# ipyleaflet
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import mapwidget.maplibre as mapwidget
|
6 |
|
7 |
import solara
|
|
|
1 |
+
|
|
|
|
|
|
|
2 |
import mapwidget.maplibre as mapwidget
|
3 |
|
4 |
import solara
|
pages/06_openlayers.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1 |
-
|
2 |
-
# ipyleaflet
|
3 |
-
Map visualization using [ipyleaflet](https://ipyleaflet.readthedocs.io/), a ipywidgets wrapper for [leaflet.js](https://leafletjs.com/)
|
4 |
-
"""
|
5 |
import mapwidget.openlayers as mapwidget
|
6 |
|
7 |
import solara
|
|
|
1 |
+
|
|
|
|
|
|
|
2 |
import mapwidget.openlayers as mapwidget
|
3 |
|
4 |
import solara
|
pages/07_ipyleaflet.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import ipyleaflet
|
2 |
+
import solara
|
3 |
+
import ipywidgets as widgets
|
4 |
+
|
5 |
+
zoom = solara.reactive(2)
|
6 |
+
center = solara.reactive((20, 0))
|
7 |
+
|
8 |
+
|
9 |
+
class Map(ipyleaflet.Map):
|
10 |
+
def __init__(self, **kwargs):
|
11 |
+
super().__init__(**kwargs)
|
12 |
+
self.layout.height = '600px'
|
13 |
+
# Add what you want below
|
14 |
+
|
15 |
+
label = widgets.Label('Clicked location')
|
16 |
+
output = widgets.Output()
|
17 |
+
widget = widgets.VBox([label, output])
|
18 |
+
control = ipyleaflet.WidgetControl(widget=widget, position='bottomright')
|
19 |
+
self.add_control(control)
|
20 |
+
|
21 |
+
def handle_interaction(**kwargs):
|
22 |
+
latlon = kwargs.get("coordinates")
|
23 |
+
if kwargs.get("type") == "click":
|
24 |
+
with output:
|
25 |
+
output.clear_output()
|
26 |
+
print(latlon)
|
27 |
+
|
28 |
+
self.on_interaction(handle_interaction)
|
29 |
+
|
30 |
+
|
31 |
+
@solara.component
|
32 |
+
def Page():
|
33 |
+
with solara.Column(style={"min-width": "500px"}):
|
34 |
+
solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
|
35 |
+
Map.element(
|
36 |
+
zoom=zoom.value,
|
37 |
+
on_zoom=zoom.set,
|
38 |
+
center=center.value,
|
39 |
+
on_center=center.set,
|
40 |
+
scroll_wheel_zoom=True,
|
41 |
+
|
42 |
+
)
|
43 |
+
solara.Text(f"Zoom: {zoom.value}")
|
44 |
+
solara.Text(f"Center: {center.value}")
|