Jonathan Marokhovsky
commited on
Commit
·
587271e
1
Parent(s):
bdcbb5f
Initial commit
Browse files- Dockerfile +21 -0
- app.py +44 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This Dockerfile was derived from giswqs's solara-template Dockerfile
|
2 |
+
# link: https://huggingface.co/spaces/giswqs/solara-template/tree/main
|
3 |
+
FROM jupyter/base-notebook:latest
|
4 |
+
|
5 |
+
RUN mamba install -c conda-forge leafmap geopandas localtileserver -y && \
|
6 |
+
fix-permissions "${CONDA_DIR}" && \
|
7 |
+
fix-permissions "/home/${NB_USER}"
|
8 |
+
|
9 |
+
COPY requirements.txt .
|
10 |
+
RUN pip install -r requirements.txt
|
11 |
+
|
12 |
+
ENV PROJ_LIB='/opt/conda/share/proj'
|
13 |
+
|
14 |
+
USER root
|
15 |
+
RUN chown -R ${NB_UID} ${HOME}
|
16 |
+
USER ${NB_USER}
|
17 |
+
|
18 |
+
EXPOSE 8765
|
19 |
+
|
20 |
+
CMD ["solara", "run", "./pages", "--host=0.0.0.0"]
|
21 |
+
|
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import leafmap
|
2 |
+
import solara
|
3 |
+
|
4 |
+
|
5 |
+
# variables
|
6 |
+
zoom = solara.reactive(2)
|
7 |
+
center = solara.reactive((20, 0))
|
8 |
+
|
9 |
+
# Euromap info
|
10 |
+
eurocrops_pmtiles = "https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/cholmes/eurocrops/eurocrops-all.pmtiles"
|
11 |
+
ec_style = leafmap.pmtiles_style(eurocrops_pmtiles)
|
12 |
+
|
13 |
+
|
14 |
+
class Map(leafmap.Map):
|
15 |
+
def __init__(self, **kwargs) -> None:
|
16 |
+
super().__init__(**kwargs)
|
17 |
+
self.add_stac_gui() ## TODO: make sure I need this
|
18 |
+
self.add_pmtiles(
|
19 |
+
eurocrops_pmtiles,
|
20 |
+
name="Euro Crops",
|
21 |
+
style=ec_style,
|
22 |
+
overlay=True,
|
23 |
+
show=True,
|
24 |
+
zoom_to_layer=False,
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
@solara.component
|
29 |
+
def Page():
|
30 |
+
with solara.Column(style={"min-width": "500px"}):
|
31 |
+
# solara components support reactive variables
|
32 |
+
# solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
|
33 |
+
# using 3rd party widget library require wiring up the events manually
|
34 |
+
# using zoom.value and zoom.set
|
35 |
+
Map.element( # type: ignore
|
36 |
+
zoom=zoom.value,
|
37 |
+
on_zoom=zoom.set,
|
38 |
+
center=center.value,
|
39 |
+
on_center=center.set,
|
40 |
+
scroll_wheel_zoom=True,
|
41 |
+
toolbar_ctrl=False,
|
42 |
+
data_ctrl=False,
|
43 |
+
height="780px",
|
44 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
solara
|
2 |
+
leafmap
|
3 |
+
pmtiles
|
4 |
+
geopandas
|