nismod / irv-jamaica

Jamaica Systemic Resilience Assessment Tool
MIT License
0 stars 0 forks source link

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:

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:

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.