File size: 5,268 Bytes
b1847cf
 
 
8324d6e
b1847cf
6f7e4ab
f26f5cc
00737c5
8d53210
6638e03
46ec1ae
b1847cf
 
 
9562f93
1f395fb
2e891b4
16b9f5c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc6a63a
 
 
 
16b9f5c
336e6ba
16b9f5c
 
 
2e891b4
ccf5a67
 
 
2e891b4
1f91692
 
5b06982
e83c263
 
 
 
 
 
 
 
ccf5a67
1f91692
 
 
 
5fab2b7
ccf5a67
f870c04
2e891b4
b1847cf
c1d10d6
b1847cf
 
8a48393
336e6ba
 
 
 
600ca48
7c74f2b
0ed20b8
 
6a4ab4e
7c74f2b
035ea6b
b1847cf
0d1feb5
 
 
035ea6b
46ec1ae
035ea6b
 
 
 
 
46ec1ae
035ea6b
 
 
 
 
46ec1ae
035ea6b
 
 
 
 
46ec1ae
035ea6b
 
 
0d1feb5
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import ee
import geemap
import solara
import ipywidgets as widgets


fireList = ["North Complex", "Dixie", "Cameron Peak", "August Complex"]
selected_fire = solara.reactive([fireList[0]])
dNBRvisParams = {'min': 0.0,'max': 0.8, 'palette': ['green', 'yellow','orange','red']}


class Map(geemap.Map):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.add_ee_data()
        self.add("layer_manager")
        self.add_selector()

    def add_ee_data(self):
        def calc_nbr(pre_start, pre_stop, post_start, post_stop, bbox):
                PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(pre_start, pre_stop)).mean()
                POSTgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date(post_start, post_stop)).mean()
                preNBR = PREgoesCMI.select(['CMI_C03','CMI_C06']).normalizedDifference(['CMI_C03', 'CMI_C06']).toFloat().rename('NBR')
                postNBR = POSTgoesCMI.select(['CMI_C03','CMI_C06']).normalizedDifference(['CMI_C03', 'CMI_C06']).toFloat().rename('NBR')
                dNBR = preNBR.subtract(postNBR).select('NBR')
                dNBRclipped = dNBR.clip(bbox)
                return dNBRclipped
            
        north_complex_bb = ee.Geometry.BBox(-121.616097, 39.426723, -120.668526, 40.030845)
        dixie_bb = ee.Geometry.BBox(-121.680467, 39.759303, -120.065477, 40.873387)
        cam_peak_bb = ee.Geometry.BBox(-106.014784, 40.377907, -105.116651, 40.822094)
        aug_complex_bb = ee.Geometry.BBox(-123.668726, 39.337654, -122.355860, 40.498304)
    
        north_complex = calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb)
        dixie = calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb)
        cam_peak = calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb)
        aug_complex = calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb)
            
        self.addLayer(north_complex, dNBRvisParams, 'North Complex GOES NBR', False)
        self.addLayer(dixie, dNBRvisParams, 'Dixie Complex GOES NBR', False)
        self.addLayer(cam_peak, dNBRvisParams, 'Cameron Peak GOES NBR', False)
        self.addLayer(aug_complex, dNBRvisParams, 'August Complex GOES NBR', False)

    def add_selector(self):
        selector = widgets.Dropdown(options=fireList, value="North Complex", description='Wildfire Case Study:') 
        output = widgets.Output()

        def on_selector_change(change):
            selected_fire = change['new']
            #self.clear_layers()
            if selected_fire == "North Complex":    
                self.find_layer('North Complex GOES NBR').visible = True
            elif selected_fire == "Dixie":
                self.find_layer('Dixie Complex GOES NBR').visible = True
            elif selected_fire == "Cameron Peak":
                self.find_layer('Cameron Peak GOES NBR').visible = True
            elif selected_fire == "August Complex":
                self.find_layer('August Complex GOES NBR').visible = True
            with output:
                output.clear_output()
                print(f"Selected wildfire case study: {selected_fire}")

        selector.observe(on_selector_change, names='value')
    
        widget = widgets.VBox([selector, output])
        self.add_widget(widget, position="topleft")
        


@solara.component
def Page():
    
    #with solara.Column(style={"align":"start", "min-width": "200px", "height": "200px"}):
        #solara.Select(label="Wildfire Case Study", value=selected_fire, values=fireList)
        #solara.Markdown(f"**Selected**: {selected_fire.value}")
        #solara.Button(label="Map the burn scar",) #on_click = on_button_clicked)

    
    # Isolation is required to prevent the map from overlapping navigation (when screen width < 960px)
    with solara.Column(style={"isolation": "isolate"}):
        map_widget = Map.element(
            center=[39, -120.5],
            zoom=8,
            height="600px",
        )
        
'''layers=[
                {
                    "eeObject": Map.calc_nbr('2020-08-15', '2020-08-16', '2020-09-15', '2020-09-16', north_complex_bb),
                    "visParams": dNBRvisParams,
                    "name": "North Complex GOES NBR",
                    "visible": True
                },
                {
                    "eeObject": Map.calc_nbr('2021-07-12', '2021-07-13', '2021-09-15', '2021-09-16', dixie_bb),
                    "visParams": dNBRvisParams,
                    "name": "Dixie Complex GOES NBR",
                    "visible": False
                },
                {
                    "eeObject": Map.calc_nbr('2020-08-12', '2020-08-13', '2020-09-12', '2020-09-13', cam_peak_bb),
                    "visParams": dNBRvisParams,
                    "name": "Cameron Peak GOES NBR",
                    "visible": True
                },
                {
                    "eeObject": Map.calc_nbr('2020-08-15', '2020-08-16', '2020-11-10', '2020-11-11', aug_complex_bb),
                    "visParams": dNBRvisParams,
                    "name": "August Complex GOES NBR",
                    "visible": False
                }],'''