Daniele Castellana commited on
Commit
ea3859b
Β·
1 Parent(s): 55fda2f

Merge develop (#3)

Browse files

* correct typos and add polygons

* update README

* update readme

* update readme

* update readme

* update requirements with pre-commit

* create separate file to initialise ee

README.md CHANGED
@@ -1,5 +1,6 @@
1
  # Flood mapping tool
2
 
 
3
  [![license](https://img.shields.io/github/license/OCHA-DAP/pa-aa-toolbox.svg)](https://github.com/mapaction/flood-mapping-tool/blob/main/LICENSE)
4
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5
  [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
 
1
  # Flood mapping tool
2
 
3
+ [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://mapaction-flood-map.streamlit.app/)
4
  [![license](https://img.shields.io/github/license/OCHA-DAP/pa-aa-toolbox.svg)](https://github.com/mapaction/flood-mapping-tool/blob/main/LICENSE)
5
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
6
  [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
app/pages/1_🌍_Flood_extent_analysis.py CHANGED
@@ -9,6 +9,7 @@ import streamlit as st
9
  import streamlit_ext as ste
10
  from folium.plugins import Draw, Geocoder, MiniMap
11
  from src.config_parameters import config
 
12
  from src.utils_flood_analysis import derive_flood_extents
13
  from src.utils_sidebar import add_about, add_logo
14
  from streamlit_folium import st_folium
@@ -59,14 +60,8 @@ st.markdown(
59
  unsafe_allow_html=True,
60
  )
61
 
62
-
63
  # Initialise Google Earth Engine
64
- @st.cache
65
- def _initialize_ee():
66
- ee.Initialize()
67
-
68
-
69
- _initialize_ee()
70
 
71
 
72
  # Create app
@@ -103,7 +98,7 @@ def app():
103
  draw_options={
104
  "circle": False,
105
  "polyline": False,
106
- "polygon": False,
107
  "circle": False,
108
  "marker": False,
109
  "circlemarker": False,
@@ -113,20 +108,8 @@ def app():
113
  Geocoder(add_marker=False).add_to(Map)
114
  # Add minimap to map
115
  MiniMap().add_to(Map)
116
- # Add file uploader for GeoJSON to add polygons to map
117
- # data = st.file_uploader(
118
- # "Upload a GeoJSON file to use as an ROI.",
119
- # type=["geojson", "kml", "zip"],
120
- # )
121
- # ss = st.empty()
122
- # with ss:
123
  # Export map to Streamlit
124
  output = st_folium(Map, width=800, height=600)
125
- # if data is not None:
126
- # with ss:
127
- # # gj = geojson.load(data)
128
- # # coords = gj['features'][0]['geometry']['coordinates']
129
- # st.write('Still to be implemented')
130
  with col2:
131
  # Add collapsable container for image dates
132
  with st.expander("Choose Image Dates"):
@@ -246,8 +229,7 @@ def app():
246
  """
247
  No satellite image found for the selected
248
  dates.\n\n
249
- Try changing the pass direction or the
250
- polarization.\n\n
251
  If this does not work, choose different
252
  dates: it is likely that the satellite did not
253
  cover the area of interest in the range of
 
9
  import streamlit_ext as ste
10
  from folium.plugins import Draw, Geocoder, MiniMap
11
  from src.config_parameters import config
12
+ from src.utils_ee import ee_initialize
13
  from src.utils_flood_analysis import derive_flood_extents
14
  from src.utils_sidebar import add_about, add_logo
15
  from streamlit_folium import st_folium
 
60
  unsafe_allow_html=True,
61
  )
62
 
 
63
  # Initialise Google Earth Engine
64
+ ee_initialize()
 
 
 
 
 
65
 
66
 
67
  # Create app
 
98
  draw_options={
99
  "circle": False,
100
  "polyline": False,
101
+ "polygon": True,
102
  "circle": False,
103
  "marker": False,
104
  "circlemarker": False,
 
108
  Geocoder(add_marker=False).add_to(Map)
109
  # Add minimap to map
110
  MiniMap().add_to(Map)
 
 
 
 
 
 
 
111
  # Export map to Streamlit
112
  output = st_folium(Map, width=800, height=600)
 
 
 
 
 
113
  with col2:
114
  # Add collapsable container for image dates
115
  with st.expander("Choose Image Dates"):
 
229
  """
230
  No satellite image found for the selected
231
  dates.\n\n
232
+ Try changing the pass direction.\n\n
 
233
  If this does not work, choose different
234
  dates: it is likely that the satellite did not
235
  cover the area of interest in the range of
app/pages/2_πŸ“–_Documentation.py CHANGED
@@ -140,7 +140,7 @@ st.markdown(
140
  )
141
 
142
  # Third section
143
- st.markdown("## Key limtations")
144
  st.markdown(
145
  """
146
  Radar imagery is great for detecting floods, as it is good at picking up
 
140
  )
141
 
142
  # Third section
143
+ st.markdown("## Key limitations")
144
  st.markdown(
145
  """
146
  Radar imagery is great for detecting floods, as it is good at picking up
app/src/utils_ee.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ """Module for ee-related functionalities."""
2
+ import ee
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache
7
+ def ee_initialize():
8
+ """Initialise Google Earth Engine."""
9
+ ee.Initialize()
requirements.txt CHANGED
@@ -4,3 +4,4 @@ geemap==0.17.2
4
  streamlit==1.14.1
5
  streamlit_ext==0.1.4
6
  streamlit-folium==0.7.0
 
 
4
  streamlit==1.14.1
5
  streamlit_ext==0.1.4
6
  streamlit-folium==0.7.0
7
+ pre-commit==2.18.1