Raster-based Approach
This page explains how to use DamageScanner with raster-based exposure and hazard data. This approach is especially useful when working with gridded exposure datasets, such as population grids, land use rasters, or economic value rasters.
When to Use Raster-Based Workflows
| Scenario | Raster-Based | Vector-Based |
|---|---|---|
| Gridded exposure data (e.g. land cover) | ✅ | ❌ |
| Building footprints or linear infrastructure | ❌ | ✅ |
| Country- or global-scale risk analysis | ✅ | ✅ |
| Exposure not tied to individual assets | ✅ | ❌ |
Required Inputs
You still need the same four key inputs as explained in the Overview:
- Hazard raster (e.g. flood depth, wind speed)
- Exposure raster (e.g. land use, population density)
- Vulnerability curves (CSV or DataFrame)
- Maximum damage values (CSV, dict, or DataFrame)
⚠️ Ensure both hazard and exposure rasters are in the same CRS and aligned spatially (same resolution and extent) for optimal performance.
Minimal Working Example
from damagescanner import DamageScanner
hazard = "data/hazard_flood_depth.tif"
feature_data = "data/exposure_population_density.tif"
curves = "data/vulnerability_curves.csv"
maxdam = "data/maxdam.csv"
scanner = DamageScanner(hazard, feature_data, curves, maxdam)
damage = scanner.calculate()
This returns a GeoDataFrame where each grid cell contains an estimated direct damage value.
Notes on Raster Behavior
- Exposure values are interpreted as damageable units per cell (e.g., people, € value, or m²)
- Output damage is computed as:
\
exposure * damage_fraction * max_damage
- The damage fraction is determined from the vulnerability curve, based on the hazard intensity in the same raster cell.
Common Pitfalls
⚠️ Misaligned Rasters — Make sure both rasters have the same extent, resolution, and CRS. You can use
rasterio.warporgdalwarpto resample.⚠️ Missing Data — NoData values can propagate through your analysis. Clean them or mask them before calculation.
⚠️ Unit mismatch — Hazard units and curve x-axis must match exactly (e.g., meters, m/s).
📚 See Also
API Documentation
raster
DamageScanner - a directe damage assessment toolkit.
Raster specific functions
RasterScanner(exposure_file, hazard_file, curve_path, maxdam_path, lu_crs=28992, haz_crs=4326, hazard_col='FX', dtype=np.int32, save=False, *, nan_value=None, cellsize=None, resolution=None, output_path=None, scenario_name=None, in_millions=False, crs=None, transform=None)
Run a raster-based direct damage assessment using hazard and exposure layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exposure_file
|
Path | ndarray | str
|
Path to land-use GeoTIFF or numpy array. |
required |
hazard_file
|
Path | ndarray | Dataset | str
|
Path to hazard raster or dataset. |
required |
curve_path
|
Path | DataFrame | ndarray | str
|
Vulnerability curve(s). |
required |
maxdam_path
|
Path | DataFrame | ndarray | str
|
Maximum damage values. |
required |
lu_crs
|
int
|
CRS of the land-use file (default EPSG:28992). |
28992
|
haz_crs
|
int
|
CRS of the hazard file (default EPSG:4326). |
4326
|
hazard_col
|
str
|
Column containing hazard intensity (default "FX"). |
'FX'
|
dtype
|
type
|
Output dtype for damage raster. |
int32
|
save
|
bool
|
If True, saves damage results to file. |
False
|
nan_value
|
float | int | None
|
Replace this value in the hazard raster with 0. |
None
|
cellsize
|
float | int | None
|
Cell size (m²) if exposure and hazard are arrays. |
None
|
resolution
|
float | int | None
|
Resolution in target projection (used for reprojection). |
None
|
output_path
|
str | Path | None
|
Output directory for saving results. |
None
|
scenario_name
|
str | None
|
Scenario name used for filenames. |
None
|
in_millions
|
bool
|
If True, convert results to millions. |
False
|
crs
|
int | None
|
CRS for saving output raster (optional). |
None
|
transform
|
Affine | None
|
Affine transform for saving raster (optional). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If cell size is not provided when required. |
ValueError
|
If vulnerability or max damage file has invalid structure. |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[DataFrame, ndarray, ndarray, Dataset | ndarray]
|
(damage_df, damagemap, landuse_in, hazard) - Damage per land-use category. - Damage map (grid with estimated damages). - Reprojected land-use map. - Reprojected hazard map. |
match_and_load_rasters(raster_in1, raster_in2)
Match and clip two raster files to their common spatial extent and resolution.
Code adapted from http://sciience.tumblr.com/post/101722591382/finding-the-georeferenced-intersection-between-two
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raster_in1
|
str | Path
|
Path to the first raster file. |
required |
raster_in2
|
str | Path
|
Path to the second raster file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[ndarray, ndarray, Affine]
|
(data1, data2, transform) - Clipped raster array from the first file. - Clipped raster array from the second file. - Affine transform of the intersecting region. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the rasters have different CRS or resolution. |