STRESS Tool

Show climate risk on a map of the US, with the MIT Joint Program data.
https://github.com/mit-jp/climate-risk-map

Category: Sustainable Development
Sub Category: Knowledge Platforms

Keywords

actix-web climate-change d3-geo environment geographic-data geojson map-visualization react

Last synced: about 8 hours ago
JSON representation

Repository metadata

Show climate risk on a map of the US, with the MIT Joint Program data

README.md

Socio-Environmental Systems Risk Triage

Build And Test

This is an interactive map for the MIT Center for Sustainability Science and Strategy (CS3). You can use it to combine, overlay, and diagnose landscapes of socio-economic, health, and environmental risk and injustice.

Running the code

Frontend

Backend

Dev guide: Adding a new map type

This codebase was originally designed to show maps only for counties of the USA, and thus adding maps of different regions wasn't a design intent. This resulted in it being difficult to add maps of different regions. If you're interested in adding a map of a new region with different geographic ids than the existing ones, for instance census tracts, then read on.

Database

In order to uniquely identify any region in the database, we use a compound id: geography_type, id. geography_type can be one of usa-state, usa-county, usa-city, or country. Each region needs a geography type in order to be uniquely identified to avoid collisions between ids for different geography types. For instance, it's possible that an id for a country could be identical to an id for a county in the USA. To add a new map type, you first need to add a new geography_type and then add all the relevant geo_ids for that geography type.

Backend

There should be no backend changes required besides the database update.

The map geometry: topojson file (world.json, usa.json, etc)

In order to show the map on the frontend, you need to create a topojson file for it. Keep three things in mind when creating this file:

  1. It must be small in order to load efficiently and quickly.
  2. It must be projected and sized appropriately for the svg viewing area 1175x610.
  3. If it's intended to be overlaid on top of an existing topojson file, you must use the same projection as the existing topojson file to get them to line up.

You will probably have access to a shape file, and need to convert it to topojson. Look at the map-data-cleaning repo for examples of converting shape files to topojson, projecting them, and sizing them appropriately. It's full of example scripts. They all use the d3 command line tools that you can install with npm. Read more about how to use them in this trio of blog posts Command Line Cartography, then read the scripts to understand them.

Here's an example

#!/usr/bin/env fish

shp2json "shape files/CRITHAB_LINE.shp" | # convert a shape file into geojson
    geoproject -n 'd3.geoAlbersUsa().scale(1300).translate([487.5, 305])' | # project the shape file to the US albers projection we use
    ndjson-split 'd.features' | # split the geojson file into lines, where each line is its own geographic area
    ndjson-map 'delete d.properties.singlmulti, # delete all the properties in the shape file except for the geoids. You don't need them and they take up sapce
delete d.properties.comname,
delete d.properties.sciname,
delete d.properties.spcode,
d' >temp-map.ndjson # save the file to a temporary file because you cannot pipe into geo2topo
geo2topo -n overlay=temp-map.ndjson | # convert the geojson file to a topojson file (more space efficient)
    toposimplify -p 1 -f | # simplify the topojson file so that any lines that would render smaller than 1 pixel are simplified (more space efficient)
    topoquantize 1e5 >critical-habitats-topo.json # truncate all the sig figs past 5. e.g. 1.00000000000000000001 becomes 1.00000 (more space efficient)

You should play around with toposimplify and topoquantize in order to find a good balance of space efficiency and resolution. Once you have the topojson file exported, you can copy it to frontend/public/ and load it up in the frontend code.

Frontend

This is the most complex part. The best way to go about adding a completely new region to the frontend is to search the repo for references to other topojson files, then add references to your new topojson file in those places, then update everywhere where there are typescript errors after that.

For instance, search the entire repo for usa.json. Currently it's referenced in Home.tsx and Editor.tsx. Modify those files a reference to your new file, then run yarn tsc --noEmit to see all the typescript errors and update the code to fix them. If the types work out properly, they should guide you to update the code everywhere you need to.


Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 7 days ago

Total Commits: 851
Total Committers: 4
Avg Commits per committer: 212.75
Development Distribution Score (DDS): 0.188

Commits in past year: 77
Committers in past year: 3
Avg Commits per committer in past year: 25.667
Development Distribution Score (DDS) in past year: 0.377

Name Email Commits
Cypress Frankenfeld i****s@g****m 691
Thornblaster12345 a****k@i****m 93
ethanrdsch e****1@g****m 63
Morgan Ludwig m****g@g****m 4

Issue and Pull Request metadata

Last synced: 7 days ago

Total issues: 4
Total pull requests: 107
Average time to close issues: 1 day
Average time to close pull requests: 10 days
Total issue authors: 1
Total pull request authors: 4
Average comments per issue: 0.0
Average comments per pull request: 0.08
Merged pull request: 97
Bot issues: 0
Bot pull requests: 0

Past year issues: 4
Past year pull requests: 14
Past year average time to close issues: 1 day
Past year average time to close pull requests: 4 days
Past year issue authors: 1
Past year pull request authors: 3
Past year average comments per issue: 0.0
Past year average comments per pull request: 0.0
Past year merged pull request: 11
Past year bot issues: 0
Past year bot pull requests: 0

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/mit-jp/climate-risk-map

Top Issue Authors

  • Thorny128 (4)

Top Pull Request Authors

  • cypressf (70)
  • ethanrdsch (26)
  • mjbludwig (6)
  • Thorny128 (5)

Top Issue Labels

Top Pull Request Labels


Dependencies

backend/Cargo.lock cargo
  • 256 dependencies
backend/Cargo.toml cargo
  • actix-web 4
  • chrono 0.4
  • csv 1.1
  • dotenv 0.14
  • env_logger 0.9
  • futures 0.3.17
  • log 0.4
  • serde 1.0.126
  • sqlx 0.5
frontend/package.json npm
  • @babel/core ^7.16.0 development
  • @nabla/vite-plugin-eslint ^1.4.0 development
  • @storybook/addon-actions ^6.5.9 development
  • @storybook/addon-docs ^6.5.9 development
  • @storybook/addon-essentials ^6.5.9 development
  • @storybook/addon-interactions ^6.5.9 development
  • @storybook/addon-links ^6.5.9 development
  • @storybook/builder-vite ^0.1.38 development
  • @storybook/react ^6.5.9 development
  • @storybook/testing-library ^0.0.13 development
  • @testing-library/dom ^8.11.1 development
  • @testing-library/jest-dom ^5.16.1 development
  • @testing-library/react ^12.1.2 development
  • @testing-library/user-event ^13.5.0 development
  • @types/jest ^27.0.3 development
  • @types/luxon ^1.27.1 development
  • @typescript-eslint/eslint-plugin ^5.9.0 development
  • @typescript-eslint/parser ^5.9.0 development
  • @vitejs/plugin-react ^1.3.2 development
  • babel-loader ^8.2.5 development
  • eslint ^8.6.0 development
  • eslint-config-airbnb ^19.0.4 development
  • eslint-config-prettier ^8.3.0 development
  • eslint-plugin-import ^2.25.4 development
  • eslint-plugin-jsx-a11y ^6.5.1 development
  • eslint-plugin-prettier ^4.0.0 development
  • eslint-plugin-react ^7.28.0 development
  • eslint-plugin-react-hooks ^4.3.0 development
  • eslint-plugin-storybook ^0.5.13 development
  • eslint-plugin-testing-library ^5.0.3 development
  • identity-obj-proxy ^3.0.0 development
  • jest ^27.4.3 development
  • jest-canvas-mock ^2.3.1 development
  • msw ^0.36.3 development
  • prettier ^2.5.1 development
  • rollup ^2.60.2 development
  • rollup-plugin-visualizer ^5.5.2 development
  • ts-jest ^27.1.1 development
  • ts-node ^10.4.0 development
  • vite ^2.9.13 development
  • whatwg-fetch ^3.6.2 development
  • @emotion/react ^11.4.1
  • @emotion/styled ^11.3.0
  • @mui/icons-material ^5.0.1
  • @mui/lab ^5.0.0-alpha.58
  • @mui/material ^5.0.1
  • @mui/system ^5.0.1
  • @reduxjs/toolkit ^1.6.1
  • @types/d3 ^6.2.0
  • @types/file-saver ^2.0.1
  • @types/node ^12.0.0
  • @types/papaparse ^5.3.2
  • @types/react ^17.0.24
  • @types/react-dom ^17.0.9
  • @types/react-redux ^7.1.18
  • @types/topojson-client ^3.0.0
  • classnames ^2.3.1
  • d3 ^6.2.0
  • d3-dsv ^2.0.0
  • d3-scale-chromatic ^2.0.0
  • file-saver ^2.0.5
  • gh-pages ^3.1.0
  • immutable ^4.0.0-rc.12
  • luxon ^2.0.1
  • papaparse ^5.3.1
  • react ^17.0.2
  • react-dom ^17.0.2
  • react-redux ^7.2.5
  • react-router-dom ^6.2.1
  • topojson-client ^3.1.0
  • tslib ^2.3.1
  • typescript ~4.3
frontend/yarn.lock npm
  • 1820 dependencies
.github/workflows/build-release.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/download-artifact v2 composite
  • actions/setup-node v2 composite
  • actions/upload-artifact v2 composite
  • appleboy/scp-action master composite
  • appleboy/ssh-action master composite
  • postgres 14 docker

Score: 4.430816798843313