{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Update exposure data with user-input data\n", "\n", "This notebook demonstrates how to update the exposure data in an existing Delft-FIAT model with user-input data. Examples will be shown about how to update the ground floor height and the max potential damages (this will be added later!).\n", "\n", "## **Step 0**: Import required packages\n", "First we need to import the necessary python packages." ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "from hydromt_fiat.fiat import FiatModel\n", "from hydromt.log import setuplog\n", "from pathlib import Path\n", "import shutil\n", "import copy\n", "import geopandas as gpd\n", "from hydromt.gis_utils import utm_crs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## **Step 1**: Configure\n", "The first step is to set up the configuration needed to initialize the FIAT model. Begin by specifying where the model that should be updated is saved, locating the required data catalog, and setting up the logger." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2023-10-18 13:36:08,112 - hydromt_fiat - log - INFO - HydroMT version: 0.8.0\n" ] } ], "source": [ "model_folder = Path().absolute() / \"data\" / \"update_ground_floor_height\" / \"fiat_model\"\n", "data_catalog = Path().absolute() / \"data\" / \"hydromt_fiat_catalog_USA.yml\"\n", "logger = setuplog(\"hydromt_fiat\", log_level=10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## **Step 2**: Initialize and read existing model\n", "In this step we initialize HydroMT-FIAT in read-mode (`mode=\"r\"`) with the `model_folder`, `data_catalog`, and `logger` that we defined above. We also read in the existing dummy model." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2023-10-18 13:36:08,144 - hydromt_fiat - data_catalog - INFO - Parsing data catalog from c:\\Repositories\\hydromt_fiat\\examples\\data\\hydromt_fiat_catalog_USA.yml\n", "2023-10-18 13:36:08,148 - hydromt_fiat - log - DEBUG - Appending log messages to file c:\\Repositories\\hydromt_fiat\\examples\\data\\update_ground_floor_height\\fiat_model\\hydromt.log.\n", "2023-10-18 13:36:08,148 - hydromt_fiat - model_api - INFO - Initializing fiat model from hydromt_fiat (v0.2.1.dev0).\n", "2023-10-18 13:36:08,149 - hydromt_fiat - fiat - INFO - Reading model data from c:\\Repositories\\hydromt_fiat\\examples\\data\\update_ground_floor_height\\fiat_model\n", "2023-10-18 13:36:08,150 - hydromt_fiat - model_api - DEBUG - User defined config read from c:\\Repositories\\hydromt_fiat\\examples\\data\\update_ground_floor_height\\fiat_model\\settings.toml\n", "2023-10-18 13:36:08,150 - hydromt_fiat - fiat - INFO - Reading model table files.\n", "2023-10-18 13:36:08,151 - hydromt_fiat - fiat - DEBUG - Reading vulnerability table c:\\Repositories\\hydromt_fiat\\examples\\data\\update_ground_floor_height\\fiat_model\\vulnerability\\vulnerability_curves.csv\n", "2023-10-18 13:36:08,208 - hydromt_fiat - fiat - DEBUG - Reading exposure table c:\\Repositories\\hydromt_fiat\\examples\\data\\update_ground_floor_height\\fiat_model\\exposure\\exposure.csv\n", "2023-10-18 13:36:08,220 - hydromt_fiat - fiat - INFO - Reading exposure geometries.\n", "2023-10-18 13:36:08,221 - hydromt_fiat - exposure_vector - INFO - Setting geometry name to building_points...\n", "2023-10-18 13:36:08,256 - hydromt_fiat - exposure_vector - INFO - Setting exposure geometries...\n" ] } ], "source": [ "fm = FiatModel(root=model_folder, mode=\"r\", data_libs=[data_catalog], logger=logger)\n", "fm.read()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## **Step 3**: Update the Ground Floor Height of the exposure data\n", "Next, we will update the Ground Floor Height of some of the exposure assets in our model. We have created some ficticious data that represents elevation certificates. We will first inspect the current exposure data and ground floor heights and the \"elevation certificate\" data.\n", "\n", "As can be seen below, apparently the ground floor height of all assets is set to 1 (foot)." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([1], dtype=int64)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "original_exposure = fm.exposure.get_full_gdf(fm.exposure.exposure_db)\n", "original_exposure[\"Ground Floor Height\"].unique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we will load the \"elevation certificate\" data and visualize it together with the exposure assets below on the map." ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/html": [ "