Giter Club home page Giter Club logo

infra-risk-vis's People

Contributors

gg-ouce avatar itrcrisks avatar mz8i avatar nicholac avatar roaldl avatar thomas-fred avatar tomalrussell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

infra-risk-vis's Issues

Aggregate risk map (asset-level)

Plot sum EAD for an asset over all hazards, for a given RCP/epoch.

Limit to sufficiently common RCP/epoch combinations

Include fluvial/pluvial flooding under future scenarios once processed (WIP).

Review data, attributes

There's a variety of attributes on different assets in different sectors.

Can we handle things generically? Current map over keys gives just-about readable labels. Ordering is data-dependent, and there's no way to break attributes into logical groups, or skip or combine them in the FeatureSidebar > List.

  • water - currently only include potable network and a sample of abstraction points.
  • transport - ports and airports, road nodes? check rail nodes (distinguish junctions from stations?)
  • power - substations, check generation and lines

Separate road asset layers

Separate road classes into layers

Check vector density of tertiary/unclassified roads - especially roads around Kingston in zoomed-out view. Can tippecanoe show more data here?

Regional sidebar view

Along with #19, click a region to display a summary sidebar

  • Region name
  • charts showing direct/indirect risk over epochs, scenarios, hazards
  • charts showing breakdown by infrastructure sector
    

Support large numbers of additional feature properties

Implement a mechanism for supporting spatial data with a very large number of attributes, without increasing the size of vector tiles unnecessarily.

Current options:

  • serve only basic data through MVT, build an API for fetching additional properties for the visible features, merge the data on the frontend side
  • given the small number of users, move towards generating MVT on the fly through PostGIS and a web tile server like https://github.com/urbica/martin

Plot return period (by colour) for a given hazard intensity

Noting an idea for hazard plotting: there may be a particular hazard intensity (depth/wind-speed) threshold which is particularly relevant, so the map could plot the least return period (or interpolated return period) above which that threshold would be exceeded. The intensity threshold could be controlled by a slider or numeric input.

Hazard data pipeline

  • mask zeros (or values <0.01m) to avoid plotting large non-flooded areas
  • fix coastal layer naming and display for baseline. Rename TIFFs and layer name expectations to set RCP to baseline (not 4x5) in 2010 timestep.

Map style generation and diffing

Notes on efficient style updates, seems to be a problem for some updates via react-map-gl

Following the how the code handles style updates:

Could be worth injecting some debugging if the full map repaints when we think it shouldn't need to. What precisely are we doing that forces a full style rebuild?

Adaptation options duration of disruption below 15

Triggers validation error, shows up as internal server error in adaptation options table.

...
  File "pydantic/main.py", line 511, in pydantic.main.BaseModel.parse_obj
  File "pydantic/main.py", line 331, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for AdaptationCostBenefitRatioParameters
eael_days
  ensure this value is greater than or equal to 1 (type=value_error.number.not_ge; limit_value=1)

Selected feature is not deselected when hiding parent layer

When hiding a layer from view, if the selected feature comes from that layer, the selection should be cleared.
Currently, the highlighted selection is still displayed, even though all other features of that layer aren't visible.

Steps to reproduce:

  • click on a feature to select
  • hide layer to which the feature belongs
  • the highlighted feature is still visible

Source code management for releases/versions

There have been a series of versions and releases, project-driven:

  • Argentina (released and handed over) - tag v0.1-argentina
  • SEAsia (released and handed over) - tag v0.2-seasia
  • Jamaica (released, may have further development) - tag v0.3.0
  • Caribbean (released, may have small changes) - branch feature/caribbean-prototype
  • HVT East Africa (in development, to demo) - branch feature/hvt-vis
  • GRI (next)

Requirements:

  • main branch development should work towards configurability and general use
  • project deployments need specific configuration
  • there is now some overlap in projects, which may see maintenance or further development

Suggest:

  • explicit release branches for tools as deployed
  • main line work going forward will be mostly focussed on GRI
  • leave open the question of design to handle multiple levels/collections of analysis, auth and access, currently keeping things separate and branching off the codebase.

Display mapped damage values for hovered features in tooltip

The goal is to display the mapped damage value of the hovered feature in the hover tooltip.

Currently, the direct damages values which are shown as colours on the infrastructure map, are not shown anywhere in text.
While the Expected Annual Damage values are shown in bulk in the selected feature sidebar, the data for the current parameters is not displayed in the hover tooltip, and the total damage figures are not displayed anywhere in the app.

Plot asset EAD over time, scenarios in sidebar

Plot line chart in asset sidebar, EAD against epoch, different colours for RCPs, separate plot per hazard.

Example vega-lite spec - to be constructed from asset attributes:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": 300,
  "height": 200,
  "data": {"values": [
    {"rcp":     "2.6", "epoch": "2050", "ead":  5210000},
    {"rcp":     "2.6", "epoch": "2100", "ead":  7520000},
    {"rcp":     "baseline", "epoch":    "2010", "ead":  4250000},
    {"rcp":     "4.5", "epoch": "2030", "ead":  4800000},
    {"rcp":     "4.5", "epoch": "2050", "ead":  5250000},
    {"rcp":     "4.5", "epoch": "2100", "ead":  8100000},
    {"rcp":     "8.5", "epoch": "2030", "ead":  4850000},
    {"rcp":     "8.5", "epoch": "2050", "ead":  5610000},
    {"rcp":     "8.5", "epoch": "2100", "ead":  10500000}
  ]},
  "mark": {
    "type": "line",
    "point": {
      "filled": true
    }
  },
  "encoding": {
    "x": {"field": "epoch", "timeUnit": "year", "title": "Year"},
    "y": {"field": "ead", "type": "quantitative", "title": "Expected Annual Damages"},
    "color": {"field": "rcp", "type": "nominal", "title": "RCP"}
  }
}

Query point location for all exposure

For a given location - which may be a current or future infrastructure asset location - I would like to know all the hazards which may affect it.

  • Do any hazards have no effect on the location? In that case, report no exposure.
  • What are the depths/wind speeds at all return periods? Line graph with 1/return period on x-axis, depth on y-axis.
  • What are the likelihoods of extremes, from an event set? Histogram of depths.

Implementation notes - may be an API call rather than pushing all data client side:

GET /exposure/rp?lat=0.00&lng=0.00

[
  {
    "hazard": "coastal", 
    "exposure": [0,0,0,1,2], 
    "return_period": [5,10,50,100,250] 
  }
]

^ exposure and return period entries correspond

GET /exposure/events?lat=0.00&lng=0.00

[
  {
    "hazard": "coastal", 
    "events": [2.3,7,2.3]
  }
]

^ events is list of non-zero depths from event set

Selected feature highlight is broken by MVT tile separation

The current highlight mechanism seems to be affected by the splitting of individual features into potentially multiple vector tiles.

How to replicate:

  • hover over a long line feature, e.g. a high voltage power line spanning a large part of Jamaica - the whole feature will be highlighted
  • click on the feature, it will be selected and information will be displayed in the feature sidebar
  • move mouse away from the feature. Presumably, parts of the line will be de-highlighted, and only the immediate fragment that was clicked will be still highlighted

This seems to be because the current selection highlight mechanism doesn't work well with tiled data. Needs investigation to identify fix.

Plot intermediate results

Colour transport assets / buidlings by economics (total/sector):

  • transport flow allocation
  • building economic sector allocation

Organisation of sidebar UI - how to select what is mapped

Organise layer selection sidebar in the following manner:

  • collapsible sections, each representing a spatial data layer that can be shown on the map
  • sections have a "style" subsection (whenever relevant) which allows the user to choose what data is mapped on top of the selected spatial data (e.g. regions -> choose from population, aggregate damages etc)
  • both the spatial layers (sidebar sections) and data styles (style dropdown entries) can be categorised into primary (focus) and secondary (context). This depends on which tab the user is currently viewing.

For example: when viewing the Risk tab, assets, regions and hazards are primary layers, while elevation is a context layer. When it comes to the regions layer, aggregate damages is a primary style option, while population and GDP are context style options.

Bug: some raster colours don't display hazard value on hover

Not all raster cells have numerical value displayed in tooltip on hover

Compare two cells from cyclones layer:
image
Screenshot_20220126_110112

The issue seems to be with the looking up of the colour value. Perhaps the colour comparison has inaccuracies that cause no lookup value to be returned from the legend.

Display raster layers, hover to show values

The aim here is to display raster data (e.g. flood return period maps showing depth of flooding) directly, coloured to show data values (depth of flooding), still visible when zoomed out, and clearly pixelated at the resolution of the data when zoomed in.

The key map interaction is to pick out the depth values and show on hover in a tooltip (Flooding: 3.2m).

Otherwise we want to show and hide layers - change climate scenario, model, return period; potentially show multiple hazards overlaid.

Notes from @mz8i :

Notes on related approaches:

Separate Repositories

Infra-Risk-Vis repository can be split into seperate repos for Backend API, UI and ETL. This could have the following benefits amoungst others:

  • Easier to pickup for developers / PR's etc
  • Easier containerised builds
  • Potential for simpler deployment to AWS services directly from repos
  • Easier to integrate into CI/CD pipelines.

HVT sustainability tool

This relates to work on AssessmentPage.tsx for the east-africa project.

  • numeric inputs
  • text notes on any changes from default
  • toggle to show/hide zero values
  • summary wording to describe final outcome "positive effect on environmental sustainability, slightly positive effect overall..."
  • add intervention
  • include generic option, default neutral for all
  • c/r/u/d locally
  • save/load to file
  • Fix weights slider (clicking resets to zero)
  • include worked example
  • map indicators to SDGs as possible - see p20 (4.1) report
  • draft guidance and guide

Reproducible development environment

Consider dependencies and requirements for the various services:

  • raster server: python + terracotta, access to TIFFs and build sqlite db
  • vector server: node + tileserver-gl-lite, access to mbtiles
  • frontend dev server: node + react etc, access to src, proxy to other endpoints
  • backend API server: python, pipenv, connect to database
  • database

Separately, snakemake workflow processes tiffs for terracotta and vector data into database then into vector tiles. Current way to run snakemake is to change to backend directory, run pipenv shell to pick up dependencies and database connection environment variables, then change over to etl and run snakemake commands.

Goal: improve ease and reproducibility of initial setup and everyday spinning up for development. See initial sketch with docker-compose for backend API and database. Current state is to open four terminals/tmux screens and run:

  • npm start
  • npm run raster
  • npm run vector
  • pipenv run uvicorn backend.app.main:app --host localhost --port 8888 (with database connection details in .env)

Cherry-pick database setup for terraform script

See

//
// Database
//
resource "aws_db_parameter_group" "pg-caribbean-dev" {
name = "pg-caribbean-dev"
family = "postgres14"
parameter {
name = "log_connections"
value = "1"
}
}
resource "aws_db_instance" "pg-caribbean-dev" {
allocated_storage = 20
max_allocated_storage = 100
engine = "postgres"
engine_version = "14.2"
instance_class = "db.t3.micro"
identifier = "pg-caribbean-dev"
name = "caribbean_dev"
username = "caribbean_dev"
port = 5432
password = var.RDS_PASSWORD
multi_az = false
db_subnet_group_name = aws_db_subnet_group.caribbean.name
vpc_security_group_ids = [aws_security_group.access.id]
parameter_group_name = aws_db_parameter_group.pg-caribbean-dev.name
publicly_accessible = true
skip_final_snapshot = true
backup_retention_period = 2
tags = {
Name = "caribbean_dev-pg-instance"
}
}
output "pg-caribbean-dev_hostname" {
description = "RDS instance hostname"
value = aws_db_instance.pg-caribbean-dev.address
sensitive = true
}
output "pg-caribbean-dev_port" {
description = "RDS instance port"
value = aws_db_instance.pg-caribbean-dev.port
sensitive = true
}
output "pg-caribbean-dev_username" {
description = "RDS instance root username"
value = aws_db_instance.pg-caribbean-dev.username
sensitive = true
}

For terraform config that sets up RDS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.