burn_mapper / pages /05_GOES_NBR.py
danielle-losos's picture
Moved Bbox creation into function
250c394 verified
raw
history blame
1.81 kB
import ee
import geemap
import solara
# Initialize the Earth Engine client library
#ee.Initialize()
fireList = ["North Complex", "Dixie", "Cameron Peak", "August Complex"]
four_fires = solara.reactive([fireList[0]])
class Map(geemap.Map):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.add_ee_data()
self.add_plot_gui()
def add_ee_data(self):
# Define the coordinates of the bounding box
bbox_coords = [[-121.616097, 39.426723], [-120.668526, 39.426723], [-120.668526, 40.030845], [-121.616097, 40.030845]]
# Create a bounding box geometry
NorthComplexBB = ee.Geometry.Polygon(bbox_coords)
PREgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date('2020-08-15', '2020-08-16')).mean()
POSTgoesCMI = ee.ImageCollection('NOAA/GOES/17/MCMIPF').filter(ee.Filter.date('2020-09-15', '2020-09-16')).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(NorthComplexBB)
dNBRvisParams = {
'min': 0.0,
'max': 0.8,
'palette': ['green', 'yellow','orange','red']}
self.addLayer(dNBR, dNBRvisParams, "GOES dNBR")
@solara.component
def Page():
solara.SelectMultiple("Wildfire Case Study", four_fires, fireList)
solara.Markdown(f"**Selected**: {four_fires.value}")
with solara.Column(style={"min-width": "500px"}):
Map.element(
center=[40, -100],
zoom=5,
height="600px",
)