update app.py
Browse files
app.py
CHANGED
@@ -138,6 +138,41 @@ if parameters_changed():
|
|
138 |
'end_date_str': end_date_str
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
# Function to calculate the frequency-specific aggregation
|
142 |
def aggregate_by_frequency(results, frequency):
|
143 |
# Create an empty list to store the aggregated results
|
|
|
138 |
'end_date_str': end_date_str
|
139 |
}
|
140 |
|
141 |
+
# Function to perform index calculations
|
142 |
+
def calculate_ndvi(image, geometry):
|
143 |
+
ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI')
|
144 |
+
result = ndvi.reduceRegion(
|
145 |
+
reducer=ee.Reducer.mean(),
|
146 |
+
geometry=geometry,
|
147 |
+
scale=30
|
148 |
+
)
|
149 |
+
return result.get('NDVI')
|
150 |
+
|
151 |
+
def calculate_ndwi(image, geometry):
|
152 |
+
ndwi = image.normalizedDifference(['B3', 'B8']).rename('NDWI')
|
153 |
+
result = ndwi.reduceRegion(
|
154 |
+
reducer=ee.Reducer.mean(),
|
155 |
+
geometry=geometry,
|
156 |
+
scale=30
|
157 |
+
)
|
158 |
+
return result.get('NDWI')
|
159 |
+
|
160 |
+
def calculate_avg_no2_sentinel5p(image, geometry):
|
161 |
+
no2 = image.select('NO2').reduceRegion(
|
162 |
+
reducer=ee.Reducer.mean(),
|
163 |
+
geometry=geometry,
|
164 |
+
scale=1000
|
165 |
+
).get('NO2')
|
166 |
+
return no2
|
167 |
+
|
168 |
+
def calculate_custom_formula(image, geometry, formula):
|
169 |
+
result = image.expression(formula).rename('Custom Index').reduceRegion(
|
170 |
+
reducer=ee.Reducer.mean(),
|
171 |
+
geometry=geometry,
|
172 |
+
scale=30
|
173 |
+
)
|
174 |
+
return result.get('Custom Index')
|
175 |
+
|
176 |
# Function to calculate the frequency-specific aggregation
|
177 |
def aggregate_by_frequency(results, frequency):
|
178 |
# Create an empty list to store the aggregated results
|