damagescanner.core

DamageScanner - a directe damage assessment toolkit

Copyright (C) 2019 Elco Koks. All versions released under the MIT license.

Module Contents

Functions

check_output_path(given_args)

Ensures given output path exists.

check_scenario_name(given_args)

Ensures given output path exists.

match_raster_to_vector(hazard, landuse, lu_crs, ...)

Matches the resolution and extent of a raster to a vector file.

RasterScanner(landuse_file, hazard_file, curve_path, ...)

Raster-based implementation of a direct damage assessment.

VectorScanner(exposure_file, hazard_file, curve_path, ...)

Vector based implementation of a direct damage assessment

damagescanner.core.check_output_path(given_args)[source]

Ensures given output path exists.

Arguments:

given_args : dict, of keyword arguments.

Returns:

str : output_path, which may be empty string (‘’)

damagescanner.core.check_scenario_name(given_args)[source]

Ensures given output path exists.

Arguments:

given_args : dict, of keyword arguments.

Returns:

str : scenario_name

damagescanner.core.match_raster_to_vector(hazard, landuse, lu_crs, haz_crs, resolution, hazard_col)[source]

Matches the resolution and extent of a raster to a vector file.

Arguments:

hazard : netCDF4 with hazard intensity per grid cell. landuse : netCDF4 with land-use information per grid cell. lu_crs : EPSG code of the land-use file. haz_crs : EPSG code of the hazard file. resolution : Desired resolution of the raster file. hazard_col : Name of the column in the hazard file that contains the hazard intensity.

damagescanner.core.RasterScanner(landuse_file, hazard_file, curve_path, maxdam_path, lu_crs=28992, haz_crs=4326, hazard_col='FX', dtype=np.int32, save=False, **kwargs)[source]

Raster-based implementation of a direct damage assessment.

Arguments:

landuse_file : GeoTiff with land-use information per grid cell. Make sure the land-use categories correspond with the curves and maximum damages (see below). Furthermore, the resolution and extend of the land-use map has to be exactly the same as the inundation map.

hazard_file : GeoTiff or netCDF4 with hazard intensity per grid cell. Make sure that the unit of the hazard map corresponds with the unit of the first column of the curves file.

curve_path : File with the stage-damage curves of the different land-use classes. Values should be given as ratios, i.e. between 0 and 1. Can also be a pandas DataFrame or numpy Array.

maxdam_path : File with the maximum damages per land-use class (in euro/m2). Can also be a pandas DataFrame or numpy Array.

dtype: Set the dtype to the requires precision. This will affect the output damage raster as well

Optional Arguments:

save : Set to True if you would like to save the output. Requires several kwargs

kwargs:

nan_value : if nan_value is provided, will mask the inundation file. This option can significantly fasten computations

cell_size : If both the landuse and hazard map are numpy arrays, manually set the cell size.

resolution : If landuse is a numpy array, but the hazard map is a netcdf, you need to specify the resolution of the landuse map.

output_path : Specify where files should be saved.

scenario_name: Give a unique name for the files that are going to be saved.

in_millions: Set to True if all values should be set in millions.

crs: Specify crs if you only read in two numpy array

transform: Specify transform if you only read in numpy arrays in order to save the result raster

Raises:

ValueError : on missing kwarg options

Returns:

damagebin : Table with the land-use class numbers (1st column) and the damage for that land-use class (2nd column).

damagemap : Map displaying the damage per grid cell of the area.

damagescanner.core.VectorScanner(exposure_file, hazard_file, curve_path, maxdam_path, cell_size=5, exp_crs=4326, haz_crs=4326, object_col='landuse', hazard_col='inun_val', centimeters=False, save=False, **kwargs)[source]

Vector based implementation of a direct damage assessment

Arguments:

exposure_file : Shapefile, Pandas DataFrame or Geopandas GeoDataFrame with land-use information of the area.

hazard_file : GeoTiff with inundation depth per grid cell. Make sure that the unit of the inundation map corresponds with the unit of the first column of the curves file.

curve_path : File with the stage-damage curves of the different land-use classes. Can also be a pandas DataFrame (but not a numpy Array).

maxdam_path : File with the maximum damages per land-use class (in euro/m2). Can also be a pandas DataFrame (but not a numpy Array).

Optional Arguments:

cell_size : Specify the cell size of the hazard map.

exp_crs : Specify the coordinate reference system of the exposure. Default is set to 4326. A preferred CRS system is in meters. Please note that the function only accepts the CRS system in the form of an integer EPSG code.

haz_crs : Specify the cooordinate reference system of the hazard. Default is set to 4326. A preferred CRS system is in meters.Please note that the function only accepts the CRS system in the form of an integer EPSG code.

centimeters : Set to True if the inundation map and curves are in centimeters

object_col : Specify the column name of the unique object id’s. Default is set to landuse.

hazard_col : Specify the column name of the hazard intensity Default is set to inun_val.

save : Set to True if you would like to save the output. Requires several kwargs

kwargs:

output_path : Specify where files should be saved.

scenario_name: Give a unique name for the files that are going to be saved.

print_tqdm: Set to False when progress output is undesired.

Raises:

ValueError : on missing kwargs

Returns:

damagebin : Table with the land-use class names (1st column) and the damage for that land-use class (2nd column).