giswqs commited on
Commit
ab1be12
1 Parent(s): a5ed0cf

Add GEE data

Browse files
pages/{01_leafmap.py → 01_earth_engine.py} RENAMED
@@ -1,15 +1,54 @@
1
  import leafmap
2
  import solara
 
 
 
3
 
4
  zoom = solara.reactive(2)
5
  center = solara.reactive((20, 0))
6
 
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  class Map(leafmap.Map):
9
  def __init__(self, **kwargs):
10
  super().__init__(**kwargs)
11
  # Add what you want below
12
- self.add_stac_gui()
 
 
 
13
 
14
 
15
  @solara.component
@@ -29,5 +68,5 @@ def Page():
29
  data_ctrl=False,
30
  height="780px",
31
  )
32
- # solara.Text(f"Zoom: {zoom.value}")
33
- # solara.Text(f"Center: {center.value}")
 
1
  import leafmap
2
  import solara
3
+ import ipywidgets as widgets
4
+ import pandas as pd
5
+
6
 
7
  zoom = solara.reactive(2)
8
  center = solara.reactive((20, 0))
9
 
10
 
11
+ def get_datasets(m):
12
+ url = 'https://raw.githubusercontent.com/opengeos/ee-tile-layers/main/datasets.tsv'
13
+ df = pd.read_csv(url, sep='\t')
14
+ setattr(m, 'df', df)
15
+ return df
16
+
17
+
18
+ def add_widget(m, position="topright"):
19
+ get_datasets(m)
20
+ df = m.df
21
+ datasets = df['id'].values.tolist()
22
+
23
+ style = {"description_width": "initial"}
24
+ padding = "0px 0px 0px 5px"
25
+
26
+ dataset = widgets.Dropdown(
27
+ options=datasets,
28
+ description="Dataset:",
29
+ style=style,
30
+ layout=widgets.Layout(padding=padding, width="275px"),
31
+ )
32
+ dataset.value = None
33
+
34
+ def dataset_changed(change):
35
+ if change["new"]:
36
+ selected = change["new"]
37
+ m.add_ee_layer(selected)
38
+
39
+ dataset.observe(dataset_changed, names="value")
40
+
41
+ m.add_widget(dataset, position=position)
42
+
43
+
44
  class Map(leafmap.Map):
45
  def __init__(self, **kwargs):
46
  super().__init__(**kwargs)
47
  # Add what you want below
48
+ self.add_basemap("SATELLITE", shown=False)
49
+ self.find_layer("Google Satellite").visible = False
50
+ self.add_layer_manager()
51
+ add_widget(self)
52
 
53
 
54
  @solara.component
 
68
  data_ctrl=False,
69
  height="780px",
70
  )
71
+ solara.Text(f"Zoom: {zoom.value}")
72
+ solara.Text(f"Center: {center.value}")