Spaces:
Sleeping
Sleeping
fix map not rendering after refresh
Browse files- pages/00_home.py +20 -18
pages/00_home.py
CHANGED
@@ -2,13 +2,13 @@ import ee
|
|
2 |
import geemap
|
3 |
import solara
|
4 |
|
|
|
5 |
class Map(geemap.Map):
|
6 |
def __init__(self, **kwargs):
|
7 |
super().__init__(**kwargs)
|
8 |
self.dataset = ee.Image("UMD/hansen/global_forest_change_2023_v1_11")
|
9 |
self.add_forest_loss_gain_data()
|
10 |
self.add_plot_gui()
|
11 |
-
# self.download_data()
|
12 |
|
13 |
def add_forest_loss_gain_data(self):
|
14 |
self.add_basemap("Esri.WorldImagery")
|
@@ -35,32 +35,34 @@ class Map(geemap.Map):
|
|
35 |
)
|
36 |
|
37 |
class PieChartPlotter:
|
38 |
-
def __init__(self):
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
def zonal_forest_area_by_country(self):
|
44 |
self.geemap.pie_chart(
|
45 |
-
|
46 |
).show()
|
47 |
|
48 |
class BarChartPlotter:
|
49 |
-
def __init__(self):
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
def zonal_forest_area_by_country(self):
|
55 |
self.geemap.bar_chart(
|
56 |
-
|
57 |
-
|
58 |
).show()
|
59 |
-
|
60 |
@solara.component
|
61 |
-
def Page():
|
62 |
with solara.Column(style={"min-width": "500px"}):
|
|
|
63 |
Map.element(
|
|
|
64 |
center=[40, -100],
|
65 |
zoom=4,
|
66 |
height="600px",
|
@@ -100,7 +102,7 @@ def Page():
|
|
100 |
|
101 |
solara.Markdown(markdown)
|
102 |
with solara.Column(style={"min-width": "500px"}):
|
103 |
-
|
104 |
|
105 |
with solara.Column(align="center"):
|
106 |
markdown = """
|
@@ -117,7 +119,7 @@ def Page():
|
|
117 |
|
118 |
solara.Markdown(markdown)
|
119 |
with solara.Column(style={"min-width": "500px"}):
|
120 |
-
bar_chart_plotter = BarChartPlotter()
|
121 |
|
122 |
with solara.Column(align="center"):
|
123 |
markdown = """
|
|
|
2 |
import geemap
|
3 |
import solara
|
4 |
|
5 |
+
|
6 |
class Map(geemap.Map):
|
7 |
def __init__(self, **kwargs):
|
8 |
super().__init__(**kwargs)
|
9 |
self.dataset = ee.Image("UMD/hansen/global_forest_change_2023_v1_11")
|
10 |
self.add_forest_loss_gain_data()
|
11 |
self.add_plot_gui()
|
|
|
12 |
|
13 |
def add_forest_loss_gain_data(self):
|
14 |
self.add_basemap("Esri.WorldImagery")
|
|
|
35 |
)
|
36 |
|
37 |
class PieChartPlotter:
|
38 |
+
def __init__(self, map_object):
|
39 |
+
if map_object is not None:
|
40 |
+
self.geemap = geemap # Access geemap instance from Map
|
41 |
+
self.zonal_forest_area_by_country()
|
42 |
+
|
43 |
def zonal_forest_area_by_country(self):
|
44 |
self.geemap.pie_chart(
|
45 |
+
"data/forest_cover.csv", names="NAME", values="sum", max_rows=20, height=400
|
46 |
).show()
|
47 |
|
48 |
class BarChartPlotter:
|
49 |
+
def __init__(self, map_object):
|
50 |
+
if map_object is not None:
|
51 |
+
self.geemap = geemap # Access geemap instance from Map
|
52 |
+
self.zonal_forest_area_by_country()
|
53 |
+
|
54 |
def zonal_forest_area_by_country(self):
|
55 |
self.geemap.bar_chart(
|
56 |
+
"data/forest_cover.csv", x="NAME", y="sum", max_rows=20, height=400,
|
57 |
+
x_label="Country", y_label="Forest area (km2)",
|
58 |
).show()
|
59 |
+
|
60 |
@solara.component
|
61 |
+
def Page():
|
62 |
with solara.Column(style={"min-width": "500px"}):
|
63 |
+
map_instance = Map()
|
64 |
Map.element(
|
65 |
+
map_object= map_instance,
|
66 |
center=[40, -100],
|
67 |
zoom=4,
|
68 |
height="600px",
|
|
|
102 |
|
103 |
solara.Markdown(markdown)
|
104 |
with solara.Column(style={"min-width": "500px"}):
|
105 |
+
plotter = PieChartPlotter(map_instance)
|
106 |
|
107 |
with solara.Column(align="center"):
|
108 |
markdown = """
|
|
|
119 |
|
120 |
solara.Markdown(markdown)
|
121 |
with solara.Column(style={"min-width": "500px"}):
|
122 |
+
bar_chart_plotter = BarChartPlotter(map_instance)
|
123 |
|
124 |
with solara.Column(align="center"):
|
125 |
markdown = """
|