Zeel commited on
Commit
5c463e0
·
1 Parent(s): 40c8b08

add RGB variants

Browse files
Files changed (1) hide show
  1. app.py +25 -22
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["mosaic_visual"] = collection.qualityMosaic("NDVI")
 
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
- jan_1 = pd.to_datetime("2024/01/01", format="%Y/%m/%d")
220
- dec_31 = pd.to_datetime("2024/12/31", format="%Y/%m/%d")
221
- nov_15 = pd.to_datetime("2024/11/15", format="%Y/%m/%d")
222
- dec_15 = pd.to_datetime("2024/12/15", format="%Y/%m/%d")
 
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=datetime.now().year, min_value=2010, step=1))
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
- st.write("<h3><div style='text-align: center;'>RGB</div></h3>", unsafe_allow_html=True)
389
- cols = st.columns(2)
390
- for col, daterange_str in zip(cols, [year_1, year_2]):
391
- start_date, end_date = daterange_str_to_dates(daterange_str)
392
- mid_date = start_date + (end_date - start_date) / 2
393
- esri_date = min(wayback_mapping.keys(), key=lambda x: abs(pd.to_datetime(x) - mid_date))
394
- with col:
395
- m = gee_folium.Map()
396
- visual_mosaic = result_df.loc[daterange_str, "mosaic_visual"]
397
- # visual_layer = gee_folium.ee_tile_layer(mosaic, {"bands": ["R", "G", "B"], "min": min_all, "max": max_all})
398
-
399
- m.add_layer(
400
- visual_mosaic.select(["R", "G", "B"])
401
- )
402
- add_geometry_to_maps([m])
403
- m.to_streamlit()
 
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)