push formulas
Browse files
app.py
CHANGED
@@ -43,13 +43,18 @@ with cols[1]:
|
|
43 |
############################################
|
44 |
# Hyperparameters
|
45 |
############################################
|
46 |
-
st.write("<
|
47 |
|
48 |
st.write("Select the vegetation indices to calculate:")
|
49 |
all_veg_indices = ["NDVI", "EVI", "EVI2"]
|
|
|
|
|
|
|
|
|
|
|
50 |
veg_indices = []
|
51 |
for veg_index in all_veg_indices:
|
52 |
-
if st.checkbox(veg_index, value=True):
|
53 |
veg_indices.append(veg_index)
|
54 |
|
55 |
st.write("Select the parameters for the EVI/EVI2 calculation (default is as per EVI's Wikipedia page)")
|
@@ -110,7 +115,7 @@ def add_indices(image, nir_band, red_band, blue_band):
|
|
110 |
ndvi = (numerator).divide(nir.add(red)).rename("NDVI").clamp(-1, 1)
|
111 |
# EVI formula taken from: https://en.wikipedia.org/wiki/Enhanced_vegetation_index
|
112 |
|
113 |
-
denominator = nir.add(red.multiply(evi_vars['C1'])).subtract(blue.multiply(evi_vars['C2'])).add(evi_vars['L'])
|
114 |
evi = numerator.divide(denominator).multiply(evi_vars['G']).rename("EVI").clamp(-1, 1)
|
115 |
evi2 = numerator.divide(nir.add(evi_vars['L']).add(red.multiply(evi_vars['C']))).multiply(evi_vars['G']).rename("EVI2").clamp(-1, 1)
|
116 |
return image.addBands([neg_cloud, ndvi, evi, evi2])
|
|
|
43 |
############################################
|
44 |
# Hyperparameters
|
45 |
############################################
|
46 |
+
st.write("<h2><div style='text-align: center;'>User Inputs</div></h2>", unsafe_allow_html=True)
|
47 |
|
48 |
st.write("Select the vegetation indices to calculate:")
|
49 |
all_veg_indices = ["NDVI", "EVI", "EVI2"]
|
50 |
+
formulas = {
|
51 |
+
"NDVI": r"$\frac{NIR - Red}{NIR + Red}$",
|
52 |
+
"EVI": r"$G \times \frac{NIR - Red}{NIR + C1 \times Red - C2 \times Blue + L}$",
|
53 |
+
"EVI2": r"$G \times \frac{NIR - Red}{NIR + L + C \times Red}$",
|
54 |
+
}
|
55 |
veg_indices = []
|
56 |
for veg_index in all_veg_indices:
|
57 |
+
if st.checkbox(f"{veg_index} = {formulas[veg_index]}", value=True):
|
58 |
veg_indices.append(veg_index)
|
59 |
|
60 |
st.write("Select the parameters for the EVI/EVI2 calculation (default is as per EVI's Wikipedia page)")
|
|
|
115 |
ndvi = (numerator).divide(nir.add(red)).rename("NDVI").clamp(-1, 1)
|
116 |
# EVI formula taken from: https://en.wikipedia.org/wiki/Enhanced_vegetation_index
|
117 |
|
118 |
+
denominator = nir.add(red.multiply(evi_vars['C1'])).subtract(blue.multiply(evi_vars['C2'])).add(evi_vars['L'])
|
119 |
evi = numerator.divide(denominator).multiply(evi_vars['G']).rename("EVI").clamp(-1, 1)
|
120 |
evi2 = numerator.divide(nir.add(evi_vars['L']).add(red.multiply(evi_vars['C']))).multiply(evi_vars['G']).rename("EVI2").clamp(-1, 1)
|
121 |
return image.addBands([neg_cloud, ndvi, evi, evi2])
|