Py.Cafe

chinchillaZ/

leafmap-solara

Libya flooding maps

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import solara
import leafmap

zoom = solara.reactive(14)
center = solara.reactive(([120.474781,23.967287]))

class Map(leafmap.Map):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # self.add_basemap("ROADMAP")
        before = "https://chinchillaz.github.io/Aowanda_landslide/Changhua_NDVI_color.tif"
        after = "https://chinchillaz.github.io/Aowanda_landslide/Changhau_true_color.tif"

        self.add_cog_layer(before, name="NDVI")
        self.add_cog_layer(after, name="True color")
        self.add("layer_manager")

        self.split_map(before, after, left_label="Before", right_label="After", add_close_button=True)


@solara.component
def Page():
    solara.lab.theme.dark = False # 把深色的關掉,就會變淺色的

    Map.element(
        center = center.value,
        zoom = zoom.value,
        on_center = center.set,
        on_zoom = zoom.set,
        height="750px"

    )

    solara.Text("Sentinel-2 True vs. NDVI (20231002) ")
    solara.Text(f"Center: {center.value}")
    solara.Text(f"Zoom: {zoom.value}")