-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFloodAreasApp.py
58 lines (42 loc) · 2.23 KB
/
FloodAreasApp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import ee
ee.Initialize()
import geemap
import pandas as pd
import streamlit as st
headContainer = st.container()
paramsContainer = st.container()
visContainer = st.container()
with headContainer:
st.title('Mapping Flood Areas Over Israel with SAR Data')
st.text('Case of winter 2019')
israel_ee = ee.FeatureCollection('USDOS/LSIB/2017').filterMetadata('COUNTRY_NA', 'equals', 'Israel')
collection = ee.ImageCollection('COPERNICUS/S1_GRD') \
.filterBounds(israel_ee) \
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV')) \
.select('VV')
before = collection.filterDate('2019-02-27', '2020-03-01').mosaic().clip(israel_ee)
after = collection.filterDate('2019-02-03', '2019-03-06').mosaic().clip(israel_ee)
DIFF_UPPER_THRESHOLD = -3
with paramsContainer:
st.text('')
st.text('')
st.header('Parametrs Definition:')
smoothingRadius = st.slider('Set radius (meters)', 20, 500, 100, step=10)
st.text('')
kernelType = st.selectbox('Set kernel type', ('circle', 'square', 'cross', 'plus', 'octagon', 'diamond'))
st.text('')
diff_smoothed = after.focal_median(smoothingRadius, kernelType , 'meters') \
.subtract(before.focal_median(smoothingRadius, kernelType, 'meters'))
diff_thresholded = diff_smoothed.lt(DIFF_UPPER_THRESHOLD)
floodMap = geemap.Map(basemap='SATELLITE', center=[31.0, 34.8], zoom=7.5, add_google_map=False)
floodMap.addLayer(before, {min:-30,max:0}, 'Before Flood', shown=True)
floodMap.addLayer(after, {min:-30,max:0}, 'After Flood', shown=True)
floodMap.addLayer(diff_smoothed, {min:-10,max:10}, 'After-Before Difference (Smoothed)', shown=True)
floodMap.addLayer(diff_thresholded.updateMask(diff_thresholded),{'palette':"0000FF"},'Flooded Areas', shown=True)
with visContainer:
st.text('')
st.header('Flood Interactive Map')
st.text('Blue areas indicate flood locations')
floodMap.to_streamlit(width=750, hight=1000)
st.text('Layers description: \n Before & After Flood images represnts unprocessed SAR data, \n Difference (Smoothed) image is the difference between the two dates of the flood event \n and Flooded Areas are selected pixels (blue) with a threshold = -3')
st.text('')