add RGB variants
Browse files
app.py
CHANGED
@@ -147,7 +147,8 @@ def process_date(daterange, satellite, veg_indices):
|
|
147 |
bucket[f"mosaic_{veg_index}"] = mosaic_veg_index
|
148 |
|
149 |
# Get median mosaic
|
150 |
-
bucket["
|
|
|
151 |
|
152 |
if satellite == "COPERNICUS/S2_SR_HARMONIZED":
|
153 |
cloud_mask_probability = fc["features"][0]["properties"]["MSK_CLDPRB"] / 100
|
@@ -216,13 +217,14 @@ for satellite in satellites:
|
|
216 |
satellite_selected[satellite] = st.checkbox(satellite, value=True, disabled=True)
|
217 |
|
218 |
# Date range input
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
223 |
input_daterange = st.date_input("Date Range (Ignore year. App will compute indices for all possible years)", (nov_15, dec_15), jan_1, dec_31)
|
224 |
min_year = int(st.number_input("Minimum Year", value=2010, min_value=2010, step=1))
|
225 |
-
max_year = int(st.number_input("Maximum Year", value=
|
226 |
|
227 |
# Input: GeoJSON/KML file
|
228 |
input_file = st.file_uploader("Upload KML/GeoJSON file", type=["geojson", "kml", "shp"])
|
@@ -385,22 +387,23 @@ if "result" in st.session_state:
|
|
385 |
m.add_child(colormap)
|
386 |
m.to_streamlit()
|
387 |
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
|
|
404 |
|
405 |
st.write("<h3><div style='text-align: center;'>Esri RGB Imagery</div></h3>", unsafe_allow_html=True)
|
406 |
cols = st.columns(2)
|
|
|
147 |
bucket[f"mosaic_{veg_index}"] = mosaic_veg_index
|
148 |
|
149 |
# Get median mosaic
|
150 |
+
bucket["mosaic_visual_max_ndvi"] = collection.qualityMosaic("NDVI")
|
151 |
+
bucket["mosaic_visual_median"] = collection.median()
|
152 |
|
153 |
if satellite == "COPERNICUS/S2_SR_HARMONIZED":
|
154 |
cloud_mask_probability = fc["features"][0]["properties"]["MSK_CLDPRB"] / 100
|
|
|
217 |
satellite_selected[satellite] = st.checkbox(satellite, value=True, disabled=True)
|
218 |
|
219 |
# Date range input
|
220 |
+
max_year = datetime.now().year
|
221 |
+
jan_1 = pd.to_datetime(f"{max_year}/01/01", format="%Y/%m/%d")
|
222 |
+
dec_31 = pd.to_datetime(f"{max_year}/12/31", format="%Y/%m/%d")
|
223 |
+
nov_15 = pd.to_datetime(f"{max_year}/11/15", format="%Y/%m/%d")
|
224 |
+
dec_15 = pd.to_datetime(f"{max_year}/12/15", format="%Y/%m/%d")
|
225 |
input_daterange = st.date_input("Date Range (Ignore year. App will compute indices for all possible years)", (nov_15, dec_15), jan_1, dec_31)
|
226 |
min_year = int(st.number_input("Minimum Year", value=2010, min_value=2010, step=1))
|
227 |
+
max_year = int(st.number_input("Maximum Year", value=max_year, min_value=2010, step=1))
|
228 |
|
229 |
# Input: GeoJSON/KML file
|
230 |
input_file = st.file_uploader("Upload KML/GeoJSON file", type=["geojson", "kml", "shp"])
|
|
|
387 |
m.add_child(colormap)
|
388 |
m.to_streamlit()
|
389 |
|
390 |
+
for name, key in zip(["RGB (Max NDVI Mosaic)", "RGB (Median Mosaic)"], ["mosaic_visual_max_ndvi", "mosaic_visual_median"]):
|
391 |
+
st.write(f"<h3><div style='text-align: center;'>{name}</div></h3>", unsafe_allow_html=True)
|
392 |
+
cols = st.columns(2)
|
393 |
+
for col, daterange_str in zip(cols, [year_1, year_2]):
|
394 |
+
start_date, end_date = daterange_str_to_dates(daterange_str)
|
395 |
+
mid_date = start_date + (end_date - start_date) / 2
|
396 |
+
esri_date = min(wayback_mapping.keys(), key=lambda x: abs(pd.to_datetime(x) - mid_date))
|
397 |
+
with col:
|
398 |
+
m = gee_folium.Map()
|
399 |
+
visual_mosaic = result_df.loc[daterange_str, key]
|
400 |
+
# visual_layer = gee_folium.ee_tile_layer(mosaic, {"bands": ["R", "G", "B"], "min": min_all, "max": max_all})
|
401 |
+
|
402 |
+
m.add_layer(
|
403 |
+
visual_mosaic.select(["R", "G", "B"])
|
404 |
+
)
|
405 |
+
add_geometry_to_maps([m])
|
406 |
+
m.to_streamlit()
|
407 |
|
408 |
st.write("<h3><div style='text-align: center;'>Esri RGB Imagery</div></h3>", unsafe_allow_html=True)
|
409 |
cols = st.columns(2)
|