ThinkHazard!

Provides a general view of the hazards, for a given location, that should be considered in project design and implementation to promote disaster and climate resilience.
https://github.com/GFDRR/thinkhazard

Category: Climate Change
Sub Category: Natural Hazard and Storms

Keywords from Contributors

openlayers geomapfish geotools jasperreports ogc reporting corse mapstore geojson

Last synced: about 4 hours ago
JSON representation

Repository metadata

ThinkHazard!

README.md

ThinkHazard!

A natural hazard screening tool for disaster risk management project planning.
ThinkHazard! is maintained by the Global Facility for Disaster Reduction and Recovery (GFDRR).

It provides classified hazard levels (very low to high) for any location in the world, along with risk management advice, reports, and contacts for 11 natural hazards.

Live site: thinkhazard.org  |  API docs: gfdrr.github.io/thinkhazard/api  |  License: GPL-3.0


Table of contents


Architecture (Docker Compose)

All services run locally inside a Docker Compose stack:

flowchart TB
    HTTP(["HTTP :8080"])

    subgraph compose["Docker Compose"]
        direction TB
        APP["ThinkHazard\nPyramid WebApp"]
        CELERY["Celery worker\n(taskrunner)"]
        REDIS["Redis"]
        PUPPETEER["Puppeteer\nPDF export"]

        subgraph pg["PostgreSQL + PostGIS"]
            PUB[("thinkhazard\n(public)")]
            ADM[("thinkhazard_admin\n(admin)")]
        end

        subgraph s3["S3 · Minio"]
        end

        MC["Minio Client\n(init)"]
    end

    HTTP --> APP
    APP --> pg
    APP --> REDIS
    APP --> PUPPETEER
    APP --> s3
    CELERY --> REDIS
    CELERY --> pg
    CELERY --> s3
    MC --> s3
Service Role
thinkhazard Pyramid web application — public site + admin interface, served on port 8080
taskrunner Celery worker — runs async tasks: publish, geopackage import, transifex sync
db PostgreSQL + PostGIS — two databases: thinkhazard (public/live) and thinkhazard_admin (staging)
redis Celery message broker
puppeteer Headless Chrome service for PDF report generation
minio S3-compatible object store for publication backups, PDF reports, and task logs
minio-client Init container that creates the S3 bucket on first startup

Getting Started

The following commands assume that the system is Debian/Ubuntu. Commands may need to be adapted when working on a different system.

Build docker images:

make build

Run the composition:

docker compose up -d
make initdb

Now point your browser to http://localhost:8080.

Run checks and automated tests:

make check test

Populate the admin database

Create the required schema and tables and populate the tables in admin database:

GPKG=path_to_geopackage_file make populatedb

Note: this may take a while.

Publication of admin database on public site

Publication consist in overwriting the public database with the admin one. This can be done using:

make publish

And this will execute as follow :

  • Lock the public site in maintenance mode.
  • Store a publication date in the admin database.
  • Backup the admin database in archives folder.
  • Create a new fresh public database.
  • Restore the admin backup into public database.
  • Unlock the public site from maintenance mode.

Configure admin username/password

Authentication is based on environment variable HTPASSWORDS which should contain
usernames and passwords using Apache htpasswd file format.

To create an authentification file .htpasswd with admin as the initial user:

htpasswd -c .htpasswd admin

It will prompt for the passwd.

Add or modify username2 in the password file .htpasswd:

htpasswd .htpasswd username2

Then pass the content of the file to environment variable:

environment:
  HTPASSWORDS: |
    admin:admin
    user:user

Analytics

If you want to get some analytics on the website usage (via Google analytics), you can add the tracking code using an analytics variable:

environment:
  ANALYTICS: UA-75301865-1

Feedback

The feedback_form_url can be configured in the production.ini file:

feedback_form_url = https://...

Translations

ThinkHazard! is translated using Transifex.

Workflow

We use lingua to extract translation string from jinja2 templates.

Note: the following should be done from the production instance ONLY in order to have
the up-to-date database strings extracted!
You will have to make sure that the ~/.transifexrc is valid and the
credentials correspond to the correct rights.

Push the UI translation sources to transifex:

make transifex-push-ui

Push the database translation sources to transifex:

make transifex-push-db

Once the translations are OK on Transifex it's possible to pull the translations:

make transifex-pull-db

Don't forget to compile the catalog (ie. convert .po to .mo):

make compile_catalog

Development

There are 3 different ways to translate strings in the templates:

  • translate filter

    This should be used for strings corresponding to enumeration tables in
    database.

    {{ hazard.title | translate }}
    
  • gettext method

    To be used for any UI string.

    {{gettext('Download PDF')}}
    
  • model class method

    Some model classes have specific method to retrive the value from a field
    specific to chosen language.

    {{ division.translated_name(request.locale_name)}}
    

Debugging with VS Code

Copy the override sample:

cp docker-compose.override.sample.yaml docker-compose.override.yaml

Then create .vscode/launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: Remote Attach Thinkhazard",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ]
        },
        {
            "name": "Python Debugger: Remote Attach Taskrunner",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5679
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ]
        },
        {
            "name": "Python Debugger: Remote Attach Tests",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5680
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ]
        }
    ]
}

Owner metadata


GitHub Events

Total
Last Year

Committers metadata

Last synced: 20 days ago

Total Commits: 1,321
Total Committers: 18
Avg Commits per committer: 73.389
Development Distribution Score (DDS): 0.677

Commits in past year: 136
Committers in past year: 4
Avg Commits per committer in past year: 34.0
Development Distribution Score (DDS) in past year: 0.551

Name Email Commits
Pierre GIRAUD p****d@c****m 427
arnaud.morvan@camptocamp.com a****n@c****m 328
Antoine Abt a****e@a****m 208
Éric Lemoine e****e@g****m 121
Ronit Jadhav r****v@c****m 50
Tobias Kohr t****r@c****m 41
François Van Der Biest f****t@c****m 40
Stuart Fraser s****1@g****m 37
Mattia Amadio 4****o 23
marionb m****r@c****m 19
Julien Acroute j****e@c****m 8
Javier Daza j****s@g****m 5
dependabot[bot] 4****] 4
tsauerwein t****n@c****m 4
Mattia Amadio 4****C 3
Marion Baumgartner m****r@i****l 1
Arnaud Morvan a****n@g****m 1
Ariel Núñez i****l@g****m 1

Committer domains:


Issue and Pull Request metadata

Last synced: 26 days ago

Total issues: 73
Total pull requests: 92
Average time to close issues: over 3 years
Average time to close pull requests: 5 months
Total issue authors: 9
Total pull request authors: 8
Average comments per issue: 3.55
Average comments per pull request: 0.59
Merged pull request: 68
Bot issues: 0
Bot pull requests: 8

Past year issues: 23
Past year pull requests: 21
Past year average time to close issues: 6 months
Past year average time to close pull requests: 3 days
Past year issue authors: 2
Past year pull request authors: 4
Past year average comments per issue: 2.7
Past year average comments per pull request: 0.48
Past year merged pull request: 7
Past year bot issues: 0
Past year bot pull requests: 2

More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/GFDRR/thinkhazard

Top Issue Authors

  • matamadio (32)
  • stufraser1 (26)
  • vdeparday (5)
  • pzwsk (5)
  • pgiraud (1)
  • martyclark (1)
  • arnaud-morvan (1)
  • ingenieroariel (1)
  • EceOzen (1)

Top Pull Request Authors

  • arnaud-morvan (51)
  • tkohr (15)
  • ronitjadhav (9)
  • dependabot[bot] (8)
  • tonio (5)
  • matamadio (2)
  • stufraser1 (1)
  • pgiraud (1)

Top Issue Labels

  • 1stpriority (17)
  • enhancement (8)
  • 2ndpriority (8)
  • v3 potential (8)
  • 3rdpriority (4)
  • Support (2)
  • data issue (1)
  • bug (1)
  • question (1)

Top Pull Request Labels

  • dependencies (8)
  • javascript (4)

Package metadata

proxy.golang.org: github.com/gfdrr/thinkhazard

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/gfdrr/thinkhazard#section-documentation
  • Licenses: gpl-3.0
  • Latest release: v2.0.10+incompatible (published about 8 years ago)
  • Last Synced: 2026-04-17T10:09:51.735Z (26 days ago)
  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.395%
    • Average: 5.576%
    • Dependent repos count: 5.758%
proxy.golang.org: github.com/GFDRR/thinkhazard

  • Homepage:
  • Documentation: https://pkg.go.dev/github.com/GFDRR/thinkhazard#section-documentation
  • Licenses: gpl-3.0
  • Latest release: v2.0.10+incompatible (published about 8 years ago)
  • Last Synced: 2026-04-17T10:09:51.751Z (26 days ago)
  • Versions: 11
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Rankings:
    • Dependent packages count: 5.395%
    • Average: 5.576%
    • Dependent repos count: 5.758%

Dependencies

package.json npm
  • bootlint ~0.11.0
  • bootstrap 3.3.7
  • casperjs ~1.1.4
  • d3 ~3.5.16
  • d3-geo-projection ~0.2.16
  • font-awesome ~4.5.0
  • jquery ~3.3.1
  • jshint ~2.5.1
  • leaflet ~0.7.7
  • less ~1.7.5
  • openlayers ~4.0.1
  • topojson ~1.6.24
  • typeahead.js ~0.11.1
requirements-dev.txt pypi
  • WebTest * development
  • coverage * development
  • flake8 * development
  • mock * development
  • nose * development
  • pep8-naming * development
  • pydevd * development
requirements.txt pypi
  • APScheduler *
  • Babel *
  • PyPDF2 *
  • SQLAlchemy *
  • alembic *
  • asyncio *
  • boto3 *
  • celery *
  • colorlog *
  • geoalchemy2 *
  • gunicorn *
  • httplib2 *
  • jinja2 *
  • lingua *
  • markdown *
  • papyrus *
  • passlib *
  • paste *
  • psycopg2 *
  • pyppeteer *
  • pyproj *
  • pyquery *
  • pyramid <2
  • pyramid_debugtoolbar *
  • pyramid_jinja2 *
  • pyramid_tm *
  • python-slugify <2.0.0
  • pytidylib *
  • pyyaml *
  • rasterio *
  • redis *
  • requests *
  • requests_futures *
  • secure <1,>=0.3
  • shapely *
  • simplejson *
  • transaction *
  • transifex-client *
  • waitress *
  • zope.sqlalchemy *
.github/workflows/ci.yaml actions
  • actions/checkout v3 composite
Dockerfile docker
  • base latest build
  • python 3.8-slim-buster build
docker/testdb/Dockerfile docker
  • camptocamp/postgres 12 build
setup.py pypi

Score: -Infinity