📘 Example: Measures and Strategies

In this notebook we will show you all the different options and inputs for creating different measures and how to create a strategy from the different measures.

Measures in FloodAdapt can be categorized into two different categories, which we will cover all in this notebook:

1. Hazard - Mitigate the hazard directly

2. Impact - Mitiage the impacts of the hazard on the assets

Strategies consist of multiple measures combined for example: StrategyXYZ = Floodwall + Elevated Homes + Pumps

If you want to learn in more detail about measures and what a strategy is, please read the sections on Measures in the FloodAdapt GUI documentation.

Import libraries

import pandas as pd
import geopandas as gpd
from pathlib import Path

from flood_adapt import FloodAdapt, Settings
from flood_adapt.objects import (
    FloodProof, FloodWall, Elevate, GreenInfrastructure, Buyout, Pump, Strategy, MeasureType, SelectionType
)
from flood_adapt import unit_system as us

🚀 Step 1. Reading-in the FloodAdapt database

Let’s start with initiating the database and FloodAdapt class. 1. Initiate the database class Settings by defining the DATABASE_ROOT and DATABASE_NAME. 2. Initiate the FloodAdapt class by parsing the Settings().database_path.

# Define the static data folder
STATIC_DATA_DIR = Path("../../_data/examples/static-data/3_Measures").resolve()

# Set up the settings for the database
settings=Settings(
    DATABASE_ROOT=Path("../../_data/examples").resolve(),
    DATABASE_NAME="charleston_test"
)

# Create the FloodAdapt instance
fa = FloodAdapt(settings.database_path)

🌧️ Step 2. Create Hazard Measures

We can divide the hazard measures into: 1. Hydraulic (grey) measures - structures such as levees, pumps, seawalls that protect infrastructure and residents 2. Green infrastructure measures - integrate natural elements like parks, green roofs, and permeable pavements into city

To create a hazard measure in Floodadapt we need to create a Measure object. Depending on the type of measure different attributes must be parsed. There are three types of hazard measures: 1. Floodwall 2. Pump 3. Green Infrastructure The green infrastructure class can be divided into sub-categories:
- Greening - Total storage - Water square

Below we will create a Measure object for each of the three hazard measure.

🧱🌊 Floodwall

When we create a floodwall object we need to specify the elevation attribute to capture the height of the floodwall. To define the elevation we need to parse a UnitfulLength object which consists of a value of type float and a unit which can be one of the UnitTypesLength. The selection_type describes the spatial type. This should be of SelectionType.polyline for a floodwall.

# Create a measure object for a Floodwall
floodwall = FloodWall(
    name="seawall_12ft",
    description="12ft Seawall",
    selection_type=SelectionType.polyline,
    polygon_file=str(STATIC_DATA_DIR / "seawall.geojson"),
    elevation=us.UnitfulLength(value=12, units=us.UnitTypesLength.feet)
)

⛽💦 Pump

When we create a pump object we need to specify the discharge attribute to capture the total river discharge in the model. To define the discharge we need to parse a UnitfulLength object which consists of a value of type float and a unit which can be one of the UnitTypesLength. The selection_type describes the spatial type. This should be of SelectionType.polygon for a pump.

# Create a measure object for a Pump
pump = Pump(
    name= "Pump",
    description="Pump",
    selection_type=SelectionType.polygon,
    polygon_file=str(STATIC_DATA_DIR / "pump.geojson"),
    discharge=us.UnitfulDischarge(value=1, units=us.UnitTypesDischarge.cfs)
)

🌱🖼️ Green infrastructure

When we create a green infrastructure object we need to specify the volume attribute to capture the total storage of the green infrastructure. o define the volume we need to parse a UnitfulVolume object which consists of a value of type float and a unit which can be one of the UnitTypesVolume. The selection_type describes the spatial type. This should be of SelectionType.polygon or SelectionType.aggregation_area for a green infrastructure. Other attributes like height and percentage are optional.

Note: GreenInfraStructure is the only measure for which it is required to pass the specific type (or sub-category as described above) to create the object, all other measures have the correct default.

# Create a measure object for Green infrastructure
greening = GreenInfrastructure(
    name= "green_infrastructure_storage",
    description="Storage through green infrastructure",
    type=MeasureType.greening,
    selection_type=SelectionType.polygon,
    polygon_file=str(STATIC_DATA_DIR / "greening.geojson"),
    volume=us.UnitfulVolume(value=43975190.31512848, units=us.UnitTypesVolume.cf),
    height=us.UnitfulHeight(value=3, units=us.UnitTypesLength.feet),
    percent_area=100.0
)

total_storage = GreenInfrastructure(
    name=  "total_storage_aggregation_area",
    description="Total Storage through green infrastructure in aggr area",
    type=MeasureType.total_storage,
    selection_type=SelectionType.aggregation_area,
    aggregation_area_type="aggr_lvl_2",
    aggregation_area_name="name5",
    volume=us.UnitfulVolume(value=100000000.0, units=us.UnitTypesVolume.cf),
)

water_square = GreenInfrastructure(
    name="w_square",
    description="Water Square",
    type=MeasureType.water_square,
    selection_type=SelectionType.polygon,
    polygon_file=str(STATIC_DATA_DIR / "water_square.geojson"),
    volume=us.UnitfulVolume(value=43975190.31512848, units=us.UnitTypesVolume.cf),
    height=us.UnitfulHeight(value=3, units=us.UnitTypesLength.feet)
)  

Let’s have a look at some of the measures. We can for example explore the floodwall. If you want to explore another measure, update the measure variable in the cell below and re-run it.

measure = floodwall # or `pump` or `greening` or `total_storage` or `water_square`
gdf = gpd.read_file(measure.polygon_file)
gdf.explore()
Make this Notebook Trusted to load map: File -> Trust Notebook

💾 Step 3. Saving the hazard measures to the database

# # Save the measures to the database
fa.save_measure(floodwall)
fa.save_measure(pump)
fa.save_measure(greening)
fa.save_measure(total_storage)
fa.save_measure(water_square)

🏠 Step 4: Create Impact Measures

To create a impact measure in Floodadapt we need to create a Measure object. In the attributes we define which type of measure we want to apply using the type attribute. Depending on the type of measure different attributes must be parsed. There are three types of impact measures: 1. Elevate 2. Buy out 3. Floodproof

We can apply measures to a specific building occupancy by defining the occupancy in the property_type attribute. For example, if we only want to buyout residential homes we can parse the building type of the residential buildings here. Make sure you parse the same string-value as you use in your Delft-FIAT model to describe that type of building.

If we want to apply the measure only in a specific aggregation area, we can define this with the aggregation_area_type, which describes the name of the aggregation area category, and the aggregation_area_name, which responds to the name of the specific aggregation area within the category.

Below we will create a Measure-object for each impact measure.

🏠⬆️ Elevate

When we create a Elevate object we need to specify the elevation attribute to capture the height of the elevation. To define the elevation we need to parse a UnitfulLengthRefValue object which consists of a value of type float, a unit which can be one of the UnitTypesLength and a vertical reference from which point the elevation should be calculated. This sholud be parsed as VerticalReference object.

# Create a measure object for elevating buildings
elevate = Elevate(
    name="elevate_homes_2ft",
    description="Elevate all residential buildings in aggregation area 1 by 2ft.",
    selection_type=SelectionType.polygon,
    property_type="residential",
    polygon_file=str(STATIC_DATA_DIR / "raise_property_polygon.geojson"),
    elevation=us.UnitfulLengthRefValue(value=2, units=us.UnitTypesLength.feet, type=us.VerticalReference.floodmap)
)

👥💰 Buyout

When we create a Buyout object we need to specify the property_type and either provide a spatial file for the area boundaries or define the aggregation_area_type and aggregation_area_name.

# Create a measure object for buying out buildings
buyout = Buyout(
    name= "buyout_all_buildings",
    description="Buyout all buildings in a specific area.",
    selection_type=SelectionType.aggregation_area,
    aggregation_area_type="aggr_lvl_2",
    aggregation_area_name="name5",
    property_type="ALL",
)

🏠🌊 Floodproof

When we create a FloodProof object we need to specify the elevation attribute to capture the height of the elevation. To define the elevation we need to parse a UnitfulLength object which consists of a value of type float, a unit which can be one of the UnitTypesLength.

# Create a measure object for flood proofing buildings
flood_proof = FloodProof(
    name="floodproof_all_com",
    description="Floodproofing all commercial buildings.",
    selection_type=SelectionType.all,
    property_type="commercial",
    elevation=us.UnitfulLength(value=2, units=us.UnitTypesLength.feet)
)

Let’s have a look at some of the measures. We can for example explore the area in which all buildings will be elevated.

measure = elevate  # or `buyout` or `flood_proof`
gdf = gpd.read_file(measure.polygon_file)
gdf.explore()
Make this Notebook Trusted to load map: File -> Trust Notebook

💾 Step 5. Saving the impact measures to the database

# Save the measures to the database
fa.save_measure(elevate)
fa.save_measure(buyout)
fa.save_measure(flood_proof)

Using the get_measures() method of the FloodAdapt class, we can check that the measures have been saved to the database.

# Get a df with all strategies
pd.DataFrame(fa.get_measures())
name description path last_modification_date geometry
0 buyout_all_buildings Buyout all buildings in a specific area. C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.556586 id name ...
1 elevate_homes_2ft Elevate all residential buildings in aggregati... C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.540973 id ...
2 floodproof_all_com Floodproofing all commercial buildings. C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.588115 None
3 green_infrastructure_storage Storage through green infrastructure C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.399198 ge...
4 Pump Pump C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.383536 ge...
5 seawall_12ft 12ft Seawall C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.383536 id ...
6 total_storage_aggregation_area Total Storage through green infrastructure in ... C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.414823 id name ...
7 w_square Water Square C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.446069 ge...

✏️ Step 6: Copying and Editing a Measure in the database

If we want to edit small parts of a measure, it is easier to copy an existing measure and edit the copy. This way we do not have to create a new measure from scratch.

A measure can be copied in the database by using the copy_measure() method of the FloodAdapt class. This method takes three arguments: the name of the measure to be copied and the name and description of the new measure. Let’s copy the measure we just created, having in mind that we want to make a measure for flood-proofing residential buildings.

# Copy measure
fa.copy_measure(
    old_name="floodproof_all_com",
    new_name="floodproof_all_res",
    new_description="Floodproofing all residential buildings."
)

We can see that now a new measure with name “floodproof_all_res” has been created in the database. However, the actual attributes of the measure are still the same as the original measure.

# Inspect Measure
floodproof_res = fa.get_measure("floodproof_all_res")
floodproof_res
FloodProof(name='floodproof_all_res', description='Floodproofing all residential buildings.', type=<MeasureType.floodproof_properties: 'floodproof_properties'>, selection_type=<SelectionType.all: 'all'>, polygon_file=None, aggregation_area_type=None, aggregation_area_name=None, property_type='commercial', elevation=UnitfulLength(value=2.0, units=UnitTypesLength.feet))

We can directly edit the relevant attributes of the measure object. In this case, we want to change the type to “residential”.

# Edit attributes
floodproof_res.property_type = "residential"

Then using the save_measure() method of the FloodAdapt class, we can save the changes to the database. This method takes a two arguments which are the Measure object and an optional boolean overwrite. The name field of the measure object provided will be used to identify which measure is going to be updated in the database, with the given Measure object attributes.

# Save updates
fa.save_measure(floodproof_res, overwrite=True)

Now we can verify that the measure has been updated in the database. The property type is now “residential”.

# Verify updates
floodproof_res = fa.get_measure("floodproof_all_res")
floodproof_res.property_type
'residential'

🧩 Step 6. Create a Strategy

Strategies are combinations measures. They allow us to run an test multiple measures in a single model run.

To create a strategy we need to create a Strategy object. In the measures attribute we parse a list of all the names of the measures that we want to apply in that strategy.

Note: All measures of a strategy need to be saved in the database before you can save the strategy itself.

# Create a strategy object
strategy = Strategy(
    name="pump_greening_flood_proof",
    description="Strategy with pump, greening and floodproofing",
    measures=[pump.name, greening.name, flood_proof.name],
)

# Save the strategy
fa.save_strategy(strategy)

Using the get_strategies() method of the FloodAdapt class, we can check that the strategies have been saved to the database.

# Get a df with all strategies
pd.DataFrame(fa.get_strategies())
name description path last_modification_date
0 no_measures C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:39:04.622285
1 pump_greening_flood_proof Strategy with pump, greening and floodproofing C:\a\FloodAdapt\FloodAdapt\docs\_data\examples... 2025-06-12 16:56:12.825110
# Inspect strategy
strategy = fa.get_strategy("pump_greening_flood_proof")
strategy
Strategy(name='pump_greening_flood_proof', description='Strategy with pump, greening and floodproofing', measures=['Pump', 'green_infrastructure_storage', 'floodproof_all_com'])

✏️ Step 7. Copying and Editing a Strategy in the database

If we want to edit small parts of a strategy, it is easier to copy an existing strategy and edit the copy. This way we do not have to create a new strategy from scratch.

A strategy can be copied in the database by using the copy_strategy() method of the FloodAdapt class. This method takes three arguments: the name of the strategy to be copied and the name and description of the new strategy. Let’s copy the strategy we just created, having in mind that we want to remove the greening from the strategy and add a floodwall instead.

# Copy strategy
fa.copy_strategy(
    old_name="pump_greening_flood_proof", 
    new_name="pump_floodwall_flood_proof", 
    new_description="Strategy with pump, flodwall and floodproofing.",
)

We can see that now a new strategy with name “pump_floodwall_flood_proof” has been created in the database. However, the actual attributes of the strtaegy are still the same as the original srtategy.

# Inspect strategy2
strategy_2 = fa.get_strategy("pump_floodwall_flood_proof")
strategy_2
Strategy(name='pump_floodwall_flood_proof', description='Strategy with pump, flodwall and floodproofing.', measures=['Pump', 'green_infrastructure_storage', 'floodproof_all_com'])

We can directly edit the relevant attributes of the measure object. In this case, we want to change the type to “residential”.

strategy_2.measures.remove(greening.name)  # Remove greening
strategy_2.measures.append(floodwall.name) # Add floodwall

Then using the save_strategy(name, overwrite=True) method of the FloodAdapt class, we can save the changes to the database. This method takes a single argument which is a Strategy object. The name field of the Strategy object provided will be used to identify which strategy is going to be updated in the database, with the given Strategy object attributes.

# Save updates
fa.save_strategy(strategy_2, overwrite=True)

Now we can verify that the strategy has been updated in the database.

# Verify updates
strategy_2 = fa.get_strategy("pump_floodwall_flood_proof")
strategy_2.measures
['Pump', 'floodproof_all_com', 'seawall_12ft']

Finished!

Congratulations you created all measures possible in FloodAdap and combined some of them into a strategy!

Back to top