TCJ21 commited on
Commit
adf9eea
Β·
1 Parent(s): 213d2b5

PR feedback

Browse files
app/pages/2_πŸ“–_Documentation.py CHANGED
@@ -1,98 +1,86 @@
1
  # """Documentation page for Streamlit app."""
2
 
3
- # import streamlit as st
4
- # from src.config_parameters import params
5
- # from src.utils import (
6
- # add_about,
7
- # set_doc_page_style,
8
- # toggle_menu_button,
9
- # )
10
-
11
- # # Page configuration
12
- # st.set_page_config(layout="wide", page_title=params["browser_title"])
13
-
14
- # # If app is deployed hide menu button
15
- # toggle_menu_button()
16
-
17
- # # Create sidebar
18
- # add_about()
19
-
20
- # # Set page style
21
- # set_doc_page_style()
22
 
23
- # # Page title
24
- # st.markdown("# Documentation")
25
 
26
- # # First section
27
- # st.markdown("## Methodology")
28
- # st.markdown(
29
- # "TODO: new documentation, only kept in Sentinel 1 section unchanged from the Mapaction tool"
30
- # )
31
 
 
 
32
 
33
- # # Second section
34
- # st.markdown("## Radar imagery for flood detection")
35
- # st.markdown(
36
- # """
37
- # While there are multiple change detections techniques for radar imagery,
38
- # the one used by Sentinel-1 is one of the simplest. Active radar satellites
39
- # produce active radiation directed at the land, and images are formed as a
40
- # function of the time it takes for that radiation to reach back to the
41
- # satellite. Because of this, radar systems are side-looking (otherwise
42
- # radiation from multiple areas would reach back at the same time). To be
43
- # detected and imaged, radiation needs to be scattered back, but not all
44
- # surfaces are equally able to scatter back, and that ability is also
45
- # influenced by the radiation's wavelength (shorter wavelengths are better at
46
- # detecting smaller objects, while longer wavelengths allow penetration,
47
- # which is good for forest canopies for example, and biomass studies).
48
- # Sentinel-1 satellites are C-band (~ 6 cm).<br><br>
49
- # Water is characterised by a mirror-like reflection mechanism, meaning that
50
- # no or very little radiation is scattered back to the satellite, so pixels
51
- # on the image will appear very dark. This very simple change detection takes
52
- # a "before" image, and looks for drops in intensity, dark spots, in the
53
- # "after" image.<br><br>
54
- # Sentinel-1 data is the result of measurements from a constellation of two
55
- # satellites, assing over the same areas following the same orbit on average
56
- # every 6 days. On Google Earth Engine, the processing level is Ground Range
57
- # Detected (GRD), meaning that it has been detected, multi-looked and
58
- # projected to ground range using an Earth ellipsoid model. GRD products
59
- # report on intensity of radiation, but have lost the phase and amplitude
60
- # information which is needed for other applications (interferometry for
61
- # example). These satellites emits in different polarizations, and can
62
- # acquire both single horizonal or vertical, or dual polarizations. Flood
63
- # water is best detected by using VH (vertical transmit and horizontal
64
- # receive), although VV (vertical transmit and vertical receive) can be
65
- # effective to identify partially submerged features. This tool uses VH
66
- # polarization. Figure 2 shows an overview of the Sentinel-1 observation
67
- # plan, where pass directions and coverage frequencies are highlighted.
68
- # """,
69
- # unsafe_allow_html=True,
70
- # )
71
 
72
- # # Add image satellite overview
73
- # st.image(
74
- # "%s" % params["url_sentinel_img"],
75
- # width=1000,
76
- # )
77
- # st.markdown(
78
- # """
79
- # <p style="font-size:%s;">
80
- # Figure 2. Overview of the Sentinel-1 observation plan (<a href=
81
- # '%s'>source</a>).
82
- # </p>
83
- # """
84
- # % (params["docs_caption_fontsize"], params["url_sentinel_img_location"]),
85
- # unsafe_allow_html=True,
86
- # )
87
 
88
- import streamlit as st
 
 
 
 
89
 
90
- slider_value = st.slider(label="number of checkboxe", min_value=1, max_value=20)
91
 
92
- checkboxes = {}
93
- for i in range(1, slider_value):
94
- checkbox = st.checkbox(f"Checkbox {i}")
95
- checkboxes[f"checkbox_{i}"] = checkbox
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
 
97
- if checkboxes["checkbox_4"]:
98
- print("checkbox 4 checked")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # """Documentation page for Streamlit app."""
2
 
3
+ import streamlit as st
4
+ from src.config_parameters import params
5
+ from src.utils import (
6
+ add_about,
7
+ set_doc_page_style,
8
+ toggle_menu_button,
9
+ )
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ # Page configuration
12
+ st.set_page_config(layout="wide", page_title=params["browser_title"])
13
 
14
+ # If app is deployed hide menu button
15
+ toggle_menu_button()
 
 
 
16
 
17
+ # Create sidebar
18
+ add_about()
19
 
20
+ # Set page style
21
+ set_doc_page_style()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ # Page title
24
+ st.markdown("# Documentation")
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ # First section
27
+ st.markdown("## Methodology")
28
+ st.markdown(
29
+ "TODO: new documentation, only kept in Sentinel 1 section unchanged from the Mapaction tool"
30
+ )
31
 
 
32
 
33
+ # Second section
34
+ st.markdown("## Radar imagery for flood detection")
35
+ st.markdown(
36
+ """
37
+ While there are multiple change detections techniques for radar imagery,
38
+ the one used by Sentinel-1 is one of the simplest. Active radar satellites
39
+ produce active radiation directed at the land, and images are formed as a
40
+ function of the time it takes for that radiation to reach back to the
41
+ satellite. Because of this, radar systems are side-looking (otherwise
42
+ radiation from multiple areas would reach back at the same time). To be
43
+ detected and imaged, radiation needs to be scattered back, but not all
44
+ surfaces are equally able to scatter back, and that ability is also
45
+ influenced by the radiation's wavelength (shorter wavelengths are better at
46
+ detecting smaller objects, while longer wavelengths allow penetration,
47
+ which is good for forest canopies for example, and biomass studies).
48
+ Sentinel-1 satellites are C-band (~ 6 cm).<br><br>
49
+ Water is characterised by a mirror-like reflection mechanism, meaning that
50
+ no or very little radiation is scattered back to the satellite, so pixels
51
+ on the image will appear very dark. This very simple change detection takes
52
+ a "before" image, and looks for drops in intensity, dark spots, in the
53
+ "after" image.<br><br>
54
+ Sentinel-1 data is the result of measurements from a constellation of two
55
+ satellites, assing over the same areas following the same orbit on average
56
+ every 6 days. On Google Earth Engine, the processing level is Ground Range
57
+ Detected (GRD), meaning that it has been detected, multi-looked and
58
+ projected to ground range using an Earth ellipsoid model. GRD products
59
+ report on intensity of radiation, but have lost the phase and amplitude
60
+ information which is needed for other applications (interferometry for
61
+ example). These satellites emits in different polarizations, and can
62
+ acquire both single horizonal or vertical, or dual polarizations. Flood
63
+ water is best detected by using VH (vertical transmit and horizontal
64
+ receive), although VV (vertical transmit and vertical receive) can be
65
+ effective to identify partially submerged features. This tool uses VH
66
+ polarization. Figure 2 shows an overview of the Sentinel-1 observation
67
+ plan, where pass directions and coverage frequencies are highlighted.
68
+ """,
69
+ unsafe_allow_html=True,
70
+ )
71
 
72
+ # Add image satellite overview
73
+ st.image(
74
+ "%s" % params["url_sentinel_img"],
75
+ width=1000,
76
+ )
77
+ st.markdown(
78
+ """
79
+ <p style="font-size:%s;">
80
+ Figure 2. Overview of the Sentinel-1 observation plan (<a href=
81
+ '%s'>source</a>).
82
+ </p>
83
+ """
84
+ % (params["docs_caption_fontsize"], params["url_sentinel_img_location"]),
85
+ unsafe_allow_html=True,
86
+ )
app/src/gfm.py CHANGED
@@ -1,7 +1,5 @@
1
  import io
2
  import os
3
- import shutil
4
- import tempfile
5
  import zipfile
6
  from pathlib import Path
7
 
@@ -78,19 +76,20 @@ def download_flood_product(area_id, product, output_file_path=None):
78
  r = requests.get(download_link)
79
  buffer = io.BytesIO(r.content)
80
 
81
- with tempfile.TemporaryDirectory() as tempdir:
82
- with zipfile.ZipFile(buffer) as z:
83
- z.extractall(tempdir)
84
- for flood_file in Path(tempdir).glob("*FLOOD*.geojson"):
85
- dest_file = output_file_path + "/" + flood_file.name
86
- shutil.copy(flood_file, dest_file)
 
87
 
88
  df = pd.DataFrame(
89
  {
90
  "aoi_id": [area_id],
91
  "datetime": [product_time],
92
  "product": [product_id],
93
- "geojson_path": [dest_file],
94
  }
95
  )
96
 
 
1
  import io
2
  import os
 
 
3
  import zipfile
4
  from pathlib import Path
5
 
 
76
  r = requests.get(download_link)
77
  buffer = io.BytesIO(r.content)
78
 
79
+ with zipfile.ZipFile(buffer, "r") as z:
80
+ namelist = z.namelist()
81
+ for name in namelist:
82
+ if "FLOOD" in name and ".geojson" in name:
83
+ flood_filename = name
84
+ break
85
+ z.extract(flood_filename, output_file_path)
86
 
87
  df = pd.DataFrame(
88
  {
89
  "aoi_id": [area_id],
90
  "datetime": [product_time],
91
  "product": [product_id],
92
+ "geojson_path": [output_file_path + "/" + flood_filename],
93
  }
94
  )
95
 
pyproject.toml CHANGED
@@ -11,6 +11,5 @@ dependencies = [
11
  "python-dotenv==1.0.1",
12
  "streamlit>=1.41.1",
13
  "streamlit-folium>=0.24.0",
14
- "ipykernel>=6.29.5",
15
- "geojson>=3.2.0",
16
  ]
 
11
  "python-dotenv==1.0.1",
12
  "streamlit>=1.41.1",
13
  "streamlit-folium>=0.24.0",
14
+ "ipykernel>=6.29.5"
 
15
  ]
uv.lock CHANGED
@@ -225,7 +225,6 @@ version = "0.1.0"
225
  source = { virtual = "." }
226
  dependencies = [
227
  { name = "folium" },
228
- { name = "geojson" },
229
  { name = "geopandas" },
230
  { name = "ipykernel" },
231
  { name = "python-dotenv" },
@@ -237,7 +236,6 @@ dependencies = [
237
  [package.metadata]
238
  requires-dist = [
239
  { name = "folium", specifier = ">=0.19.4" },
240
- { name = "geojson", specifier = ">=3.2.0" },
241
  { name = "geopandas", specifier = ">=1.0.1" },
242
  { name = "ipykernel", specifier = ">=6.29.5" },
243
  { name = "python-dotenv", specifier = "==1.0.1" },
@@ -262,15 +260,6 @@ wheels = [
262
  { url = "https://files.pythonhosted.org/packages/fc/ab/d1f47c48a14e17cd487c8b467b573291fae75477b067241407e7889a3692/folium-0.19.4-py2.py3-none-any.whl", hash = "sha256:bea5246b6a6aa61b96d1c51399dd63254bacbd6ba8a826eeb491f45242032dfd", size = 110511 },
263
  ]
264
 
265
- [[package]]
266
- name = "geojson"
267
- version = "3.2.0"
268
- source = { registry = "https://pypi.org/simple" }
269
- sdist = { url = "https://files.pythonhosted.org/packages/85/5a/33e761df75c732fcea94aaf01f993d823138581d10c91133da58bc231e63/geojson-3.2.0.tar.gz", hash = "sha256:b860baba1e8c6f71f8f5f6e3949a694daccf40820fa8f138b3f712bd85804903", size = 24574 }
270
- wheels = [
271
- { url = "https://files.pythonhosted.org/packages/18/67/a7fa2d650602731c90e0a86279841b4586e14228199e8c09165ba4863e29/geojson-3.2.0-py3-none-any.whl", hash = "sha256:69d14156469e13c79479672eafae7b37e2dcd19bdfd77b53f74fa8fe29910b52", size = 15040 },
272
- ]
273
-
274
  [[package]]
275
  name = "geopandas"
276
  version = "1.0.1"
 
225
  source = { virtual = "." }
226
  dependencies = [
227
  { name = "folium" },
 
228
  { name = "geopandas" },
229
  { name = "ipykernel" },
230
  { name = "python-dotenv" },
 
236
  [package.metadata]
237
  requires-dist = [
238
  { name = "folium", specifier = ">=0.19.4" },
 
239
  { name = "geopandas", specifier = ">=1.0.1" },
240
  { name = "ipykernel", specifier = ">=6.29.5" },
241
  { name = "python-dotenv", specifier = "==1.0.1" },
 
260
  { url = "https://files.pythonhosted.org/packages/fc/ab/d1f47c48a14e17cd487c8b467b573291fae75477b067241407e7889a3692/folium-0.19.4-py2.py3-none-any.whl", hash = "sha256:bea5246b6a6aa61b96d1c51399dd63254bacbd6ba8a826eeb491f45242032dfd", size = 110511 },
261
  ]
262
 
 
 
 
 
 
 
 
 
 
263
  [[package]]
264
  name = "geopandas"
265
  version = "1.0.1"