Authors: Kleanthis Karamvasis
Copyright: 2024 Kleanthis Karamvasis
License: GPLv3
Before running this notebook, please make sure that
Product Name | Description | Usage | Access Link |
---|---|---|---|
ERA5 | ERA5 is the fifth generation ECMWF reanalysis for the global climate and weather for the past 4 to 7 decades. ERA5 provides hourly estimates for a large number of atmospheric, ocean-wave and land-surface quantities. Data has been regridded to a regular lat-lon grid of 0.25 degrees for the reanalysis. ERA5 is updated daily with a latency of about 5 days. | Precipitation | link |
Sentinel-1 GRD | The Sentinel-1 mission comprises a constellation of two polar-orbiting satellites, operating day and night performing C-band synthetic aperture radar imaging, enabling them to acquire imagery regardless of the weather. | Backscatter changes | link |
At the end of this notebook you will be able to identify flooded regions from Sentinel-1 data using FloodPy. Be aware that the estimated run time of the notebook depends on your area of interest, your temporal span of interest and your network download speed.
The FLOODPY - FLOOD PYthon toolbox is a free and open-source python toolbox for mapping of floodwater. FLOODPY requires a specified time of interest related to the flood event and corresponding geographical boundaries. We believe that the produced maps with delineated flood-affected agricultural fields can be helpful for governments, insurers and disaster response agencies to improve flood risk assessment, relief targeting, and ultimately to protect climate-vulnerable communities from floods.
References:
Bountos, N. I., Sdraka, M., Zavras, A., Karasante, I., Karavias, A., Herekakis, T., ... & Papoutsis, I. (2023). Kuro Siwo: 12.1 billion $ m^ 2$ under the water. A global multi-temporal satellite dataset for rapid flood mapping. arXiv preprint paper link github link
In September 2023 large areas in the Mediterranean were affected by Storm Daniel. On 5-7 September 2023 Thessaly experienced extreme rainfall followed by extensive floods, resulting in the loss of human lives, livestock, harvests, land and assets. The flooding was a sudden-onset event as the floods occurred very fast.
More information: https://european-flood.emergency.copernicus.eu/en/news/storm-daniel-affects-greece-bulgaria-and-turkiye-september-2023
# The path of your project. Make sure you have enough free space disk on the specific location.
projectfolder = '/home/kleanthis/Projects/Thessalia_Floods_2023'
# Please provide a description of the flood event (e.g. Thessalia September 2023)
flood_event = 'Thessalia September 2023'
# The location of floodpy code
src_dir = '/home/kleanthis/Projects/FLOODPY/floodpy/'
# SNAP ORBIT DIRECTORY
snap_orbit_dir = '/home/kleanthis/.snap/auxdata/Orbits/Sentinel-1'
# SNAP GPT full path
GPTBIN_PATH = '/home/kleanthis/snap9/bin/gpt'
# The start and end datetimes for Pre-flood time span and flood time span (Format is YYYYMMDDTHHMMSS in UTC)
pre_flood_start = '20230803T030000'
pre_flood_end = '20230903T030000'
flood_start = '20230903T030000'
flood_end = '20230919T030000'
# Flood event spatial information
# - You can provide AOI VECTOR FILE or AOI BBOX.
# - Please ensure that your AOI BBOX has dimensions smaller than 100km x 100km
# - If you provide AOI VECTOR, AOI BBOX parameters will be ommited
# - In case you provide AOI BBOX coordinates, set AOI_File = None
# AOI VECTOR FILE (if given AOI BBOX parameters can be ommited)
AOI_File = "None"
# AOI BBOX (WGS84)
LONMIN = 21.82
LATMIN = 39.35
LONMAX = 22.30
LATMAX = 39.65
# Data access and processing
# The number of Sentinel-1 relative orbit. The default
# value is Auto. Auto means that the relative orbit that has
# the Sentinel-1 image closer to the Flood_datetime is selected.
# S1_type can be GRD or SLC.
relOrbit = 'Auto'
# The minimum mapping unit area in square meters
minimum_mapping_unit_area_m2=4000
# Computing resources to employ
CPU=8
RAM='20G'
# Credentials for Sentinel-1/2 downloading
Copernicus_username = 'Floodmappingteam@gmail.com'
Copernicus_password = '!!2024Floodpy'
ViT_model_filename = '/home/kleanthis/Projects/Thessalia_Floods_2023/Vit_model/floodvit.pt'
params_dict = {'projectfolder':projectfolder,
'flood_event':flood_event,
'src_dir' : src_dir,
'snap_orbit_dir' : snap_orbit_dir,
'GPTBIN_PATH' : GPTBIN_PATH,
'pre_flood_start' : pre_flood_start,
'pre_flood_end' : pre_flood_end,
'flood_start' : flood_start,
'flood_end' : flood_end,
'AOI_File' : AOI_File,
'LONMIN' : LONMIN,
'LATMIN' : LATMIN,
'LONMAX' : LONMAX,
'LATMAX' : LATMAX,
'relOrbit' : relOrbit,
'minimum_mapping_unit_area_m2' : minimum_mapping_unit_area_m2,
'CPU' : CPU,
'RAM' : RAM,
'Copernicus_username' : Copernicus_username,
'Copernicus_password' : Copernicus_password,
}
import pandas as pd
import copy
# FLOODPY libraries
from floodpy.FLOODPYapp import FloodwaterEstimation
from floodpy.Visualization.interactive_plotting import plot_interactive_map
from floodpy.utils.add_metadata_to_geojson import add_metadata
Floodpy_app = FloodwaterEstimation(params_dict = params_dict)
Floodpy_app.download_landcover_data()
Floodpy_app.download_ERA5_Precipitation_data()
Precipitation data can be found at /home/kleanthis/Projects/Thessalia_Floods_2023/ERA5
Floodpy_app.plot_ERA5_precipitation_data()
Floodpy_app.query_S1_data()
print('The available dates for flood mapping are: \n --> {}'.format('\n --> '.join(map(str, Floodpy_app.flood_datetimes))))
The available dates for flood mapping are: --> 2023-09-06 04:39:47.095652 --> 2023-09-07 16:24:12.139701 --> 2023-09-12 16:32:24.059385 --> 2023-09-13 04:31:57.827516 --> 2023-09-18 04:39:47.608904
print('The flooded region for the following datetimes will be calculated:')
print(*list(Floodpy_app.flood_datetimes),sep='\n')
The flooded region for the following datetimes will be calculated: 2023-09-06 04:39:47.095652 2023-09-07 16:24:12.139701 2023-09-12 16:32:24.059385 2023-09-13 04:31:57.827516 2023-09-18 04:39:47.608904
# You can also select specific flood dates following the example:
# Example -->
# Floodpy_app.flood_datetimes = [pd.Timestamp('2023-09-13 04:31:57.827516'),
# pd.Timestamp('2023-09-07 16:24:12.139701')]
Floodpy_app_objs = {}
for flood_date in Floodpy_app.flood_datetimes:
Floodpy_app.sel_S1_data(flood_date)
Floodpy_app.download_S1_GRD_products()
Floodpy_app.download_S1_orbits()
Floodpy_app.create_S1_stack(overwrite=False)
Floodpy_app.calc_flooded_regions_ViT(ViT_model_filename = ViT_model_filename,
device = 'cuda',
generate_vector = True,
overwrite = False)
Floodpy_app_objs[flood_date] = copy.deepcopy(Floodpy_app)
add_metadata(Floodpy_app_objs, Floodpy_app)
The figure can be found at: /home/kleanthis/Projects/Thessalia_Floods_2023/Results/Thessalia September 2023.svg
print("Select a singe datetime for the following list:")
print(*list(Floodpy_app_objs.keys()),sep='\n')
Select a singe datetime for the following list: 2023-09-06 04:39:47.095652 2023-09-07 16:24:12.139701 2023-09-12 16:32:24.059385 2023-09-13 04:31:57.827516 2023-09-18 04:39:47.608904
# Example: plot_interactive_map(Floodpy_app_objs[pd.Timestamp('This should be replaced')])
plot_interactive_map(Floodpy_app_objs[pd.Timestamp('2023-09-07 16:24:12.139701')])