Skip to content

nismod/irv-jamaica

Repository files navigation

Infrastructure Risk Visualisation Tool

This project provides interactive data visualisations of risk analysis results.

About

The tool presents the infrastructure systems and hazards considered in the analysis, then presents results as modelled for the whole system at a fine scale.

See an overview of infrastructure networks:

Networks

Other functionality:

  • Zoom in to see networks in detail.
  • See an overview of hazard data.
  • Inspect details of hazard layers.
  • Query attributes of elements of the system.
  • Range of potential economic impacts of failure, consisting of direct damages to infrastructure assets and indirect economic losses resulting from infrastructure service disruption (loss of power, loss of access).
  • Explore a cost-benefit analysis of adaptation measures.

This README covers requirements and steps through how to prepare data for visualisation and how to run the tool.

  1. Data preparation
  2. Build and run
  3. Deployment

Data preparation

The visualisation tool runs using prepared versions of analysis data and results:

  • Rasters stored as Cloud-Optimised GeoTIFFs, with metadata ingested into a SQLite database
  • Vector (asset or feature) data stored in a PostgreSQL database
  • Vector data preprocessed into Mapbox Vector Tiles

See ./etl directory for details.

Build and run

Running the application requires several (local) server processes: the vector and raster tileservers, the app backend, and the app frontend.

Node and npm

The build and run steps use node.js - this provides the npm command.

Install required packages. Run from the project root:

npm install

Terracotta

Install the raster tileserver - Terracotta

For example, installing using conda:

conda create --name infrariskvis python=3.8 numpy rasterio shapely crick
conda activate infrariskvis
pip install terracotta[recommended]

Run the vector tileserver

Run the tileserver directly (from the root of the project):

npm run vector

Run the raster tileserver

Prepare the raster tileserver database:

npm run raster-init

Run the raster tileserver:

npm run raster
docker run \
  --rm \
  -it \
  --workdir / \
  --mount type=bind,source="$(pwd)"/tileserver/raster/data,target=/data \
  jamaica-raster-tileserver:latest \
  terracotta ingest "/data/{type}__rp_{rp}__rcp_{rcp}__epoch_{epoch}__conf_{confidence}.tif" -o /data/terracotta.sqlite

Run the backend API server and database

Two options here.

Without docker, follow the notes in ./backend/README.md to setup a development environment for python.

Set up a postgres database and add connection details in ./backend/.env.

Run the api server:

cd ./backend
pipenv run uvicorn backend.app.main:app --host localhost --port 8888

Alternatively, run docker-compose to run the API server in one container and postgres in another.

docker compose -f docker-compose.dev.yml up db -d

PGPORT=25432 \
PGHOST=localhost \
PGUSER=docker \
PGPASSWORD=docker \
PGDATABASE=jamaica \
pg_restore -cC -j 8 -d jamaica ./archive/jamaicadev_2023-05-16.dump

Run the frontend app in development mode

Start the app server:

npm start

This should automatically open a browser tab. If not, open:

firefox http://localhost:3000/

See ./deploy directory for details.

Acknowledgements

This tool has been developed through several projects.

  • v0.1 was developed by Oxford Infrastructure Analytics for the Government of Argentina with funding support from the World Bank Group and Global Facility for Disaster Reduction and Recovery (GFDRR).
  • v0.2 was developed by Oxford Infrastructure Analytics for the Disaster Risk Financing and Insurance Program (DRFIP) of the World Bank with support from the Japan—World Bank Program for Mainstreaming DRM in Developing Countries, which is financed by the Government of Japan and managed by the Global Facility for Disaster Reduction and Recovery (GFDRR) through the Tokyo Disaster Risk Management Hub.
  • current development is by the Oxford Programme for Sustainable Infrastructure Systems in the Environmental Change Institute, University of Oxford, for the Government of Jamaica (GoJ) as part of a project funded by UK Aid (FCDO). The initiative forms part of the Coalition for Climate Resilient Investment’s (CCRI) collaboration with the GoJ, which also includes analysis of nature-based approaches to build resilience in Jamaica to be procured and funded by the Green Climate Fund (GCF).