Zeel commited on
Commit
bb7c6c8
·
1 Parent(s): 21b0f34

integrate with bhuvan

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -52,17 +52,19 @@ formulas = {
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)")
61
- cols = st.columns(5)
62
- evi_vars = {}
63
- for col, name, default in zip(cols, ["G", "C1", "C2", "L", "C"], [2.5, 6, 7.5, 1, 2.4]):
64
- value = col.number_input(f'{name}', value=default)
65
- evi_vars[name] = value
 
66
 
67
  ############################################
68
  # Functions
@@ -233,12 +235,15 @@ min_year = int(st.number_input("Minimum Year", value=2010, min_value=2010, step=
233
  max_year = int(st.number_input("Maximum Year", value=max_year, min_value=2010, step=1))
234
 
235
  # Input: GeoJSON/KML file
236
- input_file = st.file_uploader("Upload KML/GeoJSON file", type=["geojson", "kml", "shp"])
237
- if input_file is None:
 
 
 
238
  st.stop()
239
  buffer = st.number_input("Buffer (m)", value=150, min_value=0, step=1)
240
 
241
- input_gdf = preprocess_gdf(gpd.read_file(input_file))
242
 
243
  # Input: Geometry
244
  def format_fn(x):
 
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
+ defaults = [True, False, False]
56
  veg_indices = []
57
+ for veg_index, default in zip(all_veg_indices, defaults):
58
+ if st.checkbox(f"{veg_index} = {formulas[veg_index]}", value=default):
59
  veg_indices.append(veg_index)
60
 
61
+ with st.expander("EVI/EVI2 Parameters"):
62
+ st.write("Select the parameters for the EVI/EVI2 calculation (default is as per EVI's Wikipedia page)")
63
+ cols = st.columns(5)
64
+ evi_vars = {}
65
+ for col, name, default in zip(cols, ["G", "C1", "C2", "L", "C"], [2.5, 6, 7.5, 1, 2.4]):
66
+ value = col.number_input(f'{name}', value=default)
67
+ evi_vars[name] = value
68
 
69
  ############################################
70
  # Functions
 
235
  max_year = int(st.number_input("Maximum Year", value=max_year, min_value=2010, step=1))
236
 
237
  # Input: GeoJSON/KML file
238
+ file_url = st.query_params.get("file_url", None)
239
+ if file_url is None:
240
+ file_url = st.file_uploader("Upload KML/GeoJSON file", type=["geojson", "kml", "shp"])
241
+
242
+ if file_url is None:
243
  st.stop()
244
  buffer = st.number_input("Buffer (m)", value=150, min_value=0, step=1)
245
 
246
+ input_gdf = preprocess_gdf(gpd.read_file(file_url))
247
 
248
  # Input: Geometry
249
  def format_fn(x):