Functions

Regional exposure

scripts.functions.region_exposure(region, include_storms=True, event_set=False, sens_analysis_storms=[], save=True)[source]

Create a GeoDataframe with exposure and hazard information for each building in the specified region.

Arguments:

region (string) – NUTS3 code of region to consider.

include_storms (bool) – if set to False, it will only return a list of buildings and their characteristics (default: True)

event_set (bool) – if set to True, we will calculate the exposure for the event set instead of the historical storms (default: True)

sens_analysis_storms (list) – if empty, it will fill with default list

save (bool) – boolean to decide whether you want to save the output to a csv file (default: True)

Returns:
GeoDataFrame with all hazard and exposure values.

Regional losses

scripts.functions.region_losses(region, storm_event_set=False, sample=(5, 0, 95, 20, 80))[source]

Estimation of the losses for all buildings in a region for a pre-defined list of storms.

Arguments:

region (string) – nuts code of region to consider.

storm_event_set (bool) – calculates all regions within a country parallel. Set to False if you have little capacity on the machine (default: True).

sample (tuple) – tuple of parameter values. This is a dummy placeholder, should be filled with either load_sample(country) values or sens_analysis_param_list.

Returns:
pandas Dataframe – pandas dataframe with all buildings of the region and their losses for each wind storm.

Regional sensitivity analysis

scripts.functions.region_sens_analysis(region, samples, sens_analysis_storms=[], save=True)[source]

Perform a sensitivity analysis for the specified region, based on a predefined list of storms.

Arguments:

region (string) – nuts code of region to consider.

samples (list) – list o tuples, where each tuple is a unique set of parameter values.

sens_analysis_storms (list) – if empty, it will fill with default list

save (bool) – boolean to decide whether you want to save the output to a csv file (default: True)

Returns:
list – list with the total losses per storm for all parameter combinations

Loss calculation

scripts.functions.loss_calculation(storm, country, output_table, max_dam, curves, sample)[source]

Calculate the losses per storm.

Arguments:

storm (string) – date of the storm.

region (string) – NUTS3 code of region to consider.

output_table (GeoDataFrame) – GeoDataFrame with all buildings and the wind speed values for each storm.

max_dam (numpy array) – table with maximum damages per building type/land-use class.

curves (pandas dataframe) – fragility curves for the different building types.

sample (list) – ratios of different curves used in this study. See the Sensitivity analysis documentation for an explanation.

Returns:
pandas Series – losses to all buildings for the specified storm

Fetch buildings from OpenStreetMap

scripts.functions.fetch_buildings(data_path, country, region='', regional=False)[source]

This function directly reads the building data from osm, instead of first converting it to a shapefile

Arguments:

data_path (string) – string of data path where all data is located.

country (string) – ISO2 code of country to consider.

region (string) – NUTS3 code of region to consider.

regional (boolean) – Boolean to decide whether this should be done on a regional level or for the entire country (default: False).

Returns:
Geodataframe – Geopandas dataframe with all buildings in the specified region or country.

Create .poly files

scripts.functions.poly_files(data_path, country)[source]

This function will create the .poly files from the nuts shapefile. These .poly files are used to extract data from the openstreetmap files.

This function is adapted from the OSMPoly function in QGIS.

Arguments:

data_path (string) – string of data path where all data is located.

country (string) – ISO2 code of country to consider.

Returns:
.poly file – .poly file for each NUTS3 in a new directory in the working directory of the country.

Extract buildings from OpenStreetMap

scripts.functions.extract_buildings(area, country, NUTS3=True)[source]

Extracts building from OpenStreetMap pbf file and saves it to an ESRI shapefile

Arguments:

area (string) – name of area to clip

country (string) – ISO2 code of country to consider.

NUTS3 (bool) – specify whether it will be a clip of NUTS3 region or the whole country (default: True)

Convert buildings table from EPSG:4326 to EPSG:3035

scripts.functions.convert_buildings(area, country)[source]

Converts the coordinate system from EPSG:4326 to EPSG:3035.

Arguments:

area (string) – name of area (most often NUTS3) for which buildings should be converted to European coordinate system.

country (string) – ISO2 code of country to consider.

Returns:
GeoDataframe – Geopandas dataframe with all buildings of the selected area

Build list of storms

scripts.functions.get_storm_list(data_path)[source]

Small function to create a list of with path strings to all storms.

Arguments:
data_path (string) – string of data path where all data is located.
Returns:
list – list with the path strings of all storms

Build list of storms for event set

scripts.functions.get_event_storm_list(data_path)[source]

Small function to create a list of with path strings to all storms in the event set.

Arguments:
data_path (string) – string of data path where all data is located.
Returns:
list – list with the path strings of all storms

Load storms for sensitivity analysis

scripts.functions.load_sens_analysis_storms(storm_name_list=['19991203', '19900125', '20090124', '20070118', '19991226'])[source]

This file load the storms used to perform the sensitivity analysis.

Arguments:
storm_name_list (list) – list of storms to include in the sensitivity analysis. The default storms are Anatol, Daria, Klaus, Kyrill and Lothar.
Returns:
storm_list (list) – same list of storms but now with full paths to location in directory.

Load table of maximum damages

scripts.functions.load_max_dam(data_path)[source]

Small function to load the excel with maximum damages.

Arguments:
data_path (string) – string of data path where all data is located.
Returns:
dataframe – pandas dataframe with maximum damages per landuse.

Load fragility curves

scripts.functions.load_curves(data_path)[source]

Small function to load the csv file with the different fragility curves.

Arguments:
data_path (string) – string of data path where all data is located.
Returns:
dataframe – pandas dataframe with fragility curves

Load curves ratios

scripts.functions.load_sample(country)[source]

Will load the ratio of each curve and landuse to be used.

Arguments:
country (string) – ISO2 code of country to consider.
Returns:

tuple – tuple with ratios for the selected country. See the documentation for an explanation.

[‘c2’, ‘c3’, ‘c4’,’lu1’,’lu2’]

Load OpenStreetMap data

scripts.functions.load_osm_data(data_path, country, region='', regional=False)[source]

This function loads the OSM file for the country

Arguments:

data_path (string) – string of data path where all data is located.

country (string) – ISO2 code of country to consider.

region (string) – NUTS3 code of region to consider.

regional (boolean) – Boolean to decide whether this should be done on a regional level or for the entire country (default: False).

Returns:
opened OSM file to use in the fetch_roads function.

Clip landuse

scripts.functions.clip_landuse(data_path, country, region, outrast_lu)[source]

Clip the landuse from the European Corine Land Cover (CLC) map to the considered country.

Arguments:

data_path (string) – string of data path where all data is located.

country (string) – ISO2 code of country to consider.

outrast_lu (string) – string path to location of Corine Land Cover dataset

Returns:
raster (geotiff) – returns a raster file with only the landuse of the clipped region or country.

Clip OpenStreetMap file

scripts.functions.clip_osm(data_path, osm_path, area_poly, area_pbf)[source]

Clip the an area osm file from the larger continent (or planet) file and save to a new osm.pbf file.

This is much faster compared to clipping the osm.pbf file while extracting through ogr2ogr.

This function uses the osmconvert tool, which can be found at http://wiki.openstreetmap.org/wiki/Osmconvert.

Either add the directory where this executable is located to your environmental variables or just put it in the ‘scripts’ directory.

Arguments:

osm_path (string) – path string to the osm.pbf file of the continent associated with the country.

area_pol (string) – path string to the .poly file, made through the ‘create_poly_files’ function.

area_pbf (string) – path string indicating the final output dir and output name of the new .osm.pbf file.

Returns:
a clipped .osm.pbf file.

Obtain raster value from geotiff grid

scripts.functions.get_raster_value(centroid, out_image, out_transform)[source]

Small function to obtain raster value from rastermap, using point_query.

Arguments:

centroid (shapely geometry) – shapely geometry of centroid of the building.

out_image (numpy array) – numpy array of grid.

out_transform (Affine) – georeference of numpy array.

Returns:
integer – raster value corresponding to location of centroid

Create excel file with summary statistics

scripts.functions.summary_statistics_losses()[source]

This function creates the file ‘output_storms.xlsx’. This file is required to create the summary figures.

Returns:
output_storms.xlsx (excel file) – Excel file with summary outcomes