{"id":13557752,"url":"https://github.com/GFDRR/thinkhazard","last_synced_at":"2025-04-03T12:31:04.136Z","repository":{"id":26464493,"uuid":"29915977","full_name":"GFDRR/thinkhazard","owner":"GFDRR","description":"ThinkHazard!","archived":false,"fork":false,"pushed_at":"2024-08-01T22:18:10.000Z","size":23626,"stargazers_count":33,"open_issues_count":36,"forks_count":19,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-10-29T19:51:47.176Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thinkhazard.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GFDRR.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":"support_tools/ADM_processing/Patches/ADM0_patch.cpg","governance":null,"roadmap":null,"authors":"AUTHORS.txt","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-01-27T13:46:42.000Z","updated_at":"2024-09-19T12:18:50.000Z","dependencies_parsed_at":"2024-01-08T01:44:54.132Z","dependency_job_id":"50bdf589-4dc6-400e-8eaa-8387a6d05b55","html_url":"https://github.com/GFDRR/thinkhazard","commit_stats":{"total_commits":1182,"total_committers":18,"mean_commits":65.66666666666667,"dds":0.6387478849407784,"last_synced_commit":"eeb8362a96a83bb2b0b284d3e09c8e9dfca95d6e"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GFDRR%2Fthinkhazard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GFDRR%2Fthinkhazard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GFDRR%2Fthinkhazard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GFDRR%2Fthinkhazard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GFDRR","download_url":"https://codeload.github.com/GFDRR/thinkhazard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233894083,"owners_count":18746854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:04:31.571Z","updated_at":"2025-04-03T12:31:04.115Z","avatar_url":"https://github.com/GFDRR.png","language":"Python","funding_links":[],"categories":["Python","others","Climate Change"],"sub_categories":["Natural Hazard and Storms"],"readme":"# ThinkHazard\n\nA natural hazard screening tool for disaster risk management project planning. ThinkHazard! is maintained by the Global Facility for Disaster Reduction and Recovery (GFDRR). Provides classified hazard level (very low to high) for any location in the world, and advice on managing disaster risk, plus useful reports and contacts, for 11 natural hazards. \n\nAPI instructions can be found here: https://github.com/GFDRR/thinkhazard/blob/master/API.md \n\n\n\n[![Build Status](https://travis-ci.org/GFDRR/thinkhazard.svg?branch=master)](https://travis-ci.org/GFDRR/thinkhazard)\n\n## Getting Started\n\nThe following commands assume that the system is Debian/Ubuntu. Commands may need to be adapted when working on a different system.\n\nBuild docker images:\n\n    $ make build\n\nRun the composition:\n\n    $ docker-compose up -d\n    $ make initdb\n\nNow point your browser to \u003chttp://localhost:8080\u003e.\n\nRun checks and automated tests:\n\n    $ make check test\n\n## Initialize a fresh database\n\nInstall postgres `unaccent` extension database engine :\n\n    $ sudo apt install postgresql-contrib\n\nEdit `/etc/postgresql/9.5/main/postgresql.conf`, and set `max_prepared_transactions` to 10\n\nCreate a database:\n\n    $ sudo -u postgres createdb -O www-data thinkhazard_admin\n    $ sudo -u postgres psql -d thinkhazard_admin -c 'CREATE EXTENSION postgis;'\n    $ sudo -u postgres psql -d thinkhazard_admin -c 'CREATE EXTENSION unaccent;'\n    $ sudo -u postgres createdb -O www-data thinkhazard\n    $ sudo -u postgres psql -d thinkhazard -c 'CREATE EXTENSION postgis;'\n    $ sudo -u postgres psql -d thinkhazard -c 'CREATE EXTENSION unaccent;'\n\nIf you want to use a different user or different database name, you’ll have to provide your own configuration file. See “Use local.ini” section below.\n\nCreate the required schema and tables and populate the enumeration tables:\n\n    $ make populatedb\n\nNote: this may take a while. If you don’t want to import all the world administrative divisions, you can import only a subset:\n\n    $ make populatedb DATA=turkey\n\nor:\n\n    $ make populatedb DATA=indonesia\n\nIn order to harvest geonode instance with full access, you need to create and\nconfigure an API key.\nOn geonode side:\n\n* create a superuser with following command:\n\n    $ python manage.py createsuperuser\n\n* Then, create api keys for all users with:\n\n    $ python manage.py backfill_api_keys\n\n* Finally, you can display all api keys with:\n\n```sql\nSELECT people_profile.id, username, key\nFROM people_profile\nLEFT JOIN tastypie_apikey ON (tastypie_apikey.user_id = people_profile.id)\n```\n\nOn Thinkhazard side:\n\n* Change username and api_key value according to previous setup in\n`thinkhazard_processing.yaml` file.\n\nYou’re now ready to harvest, download and process the data:\n\n    $ make harvest\n    $ make download\n    $ make complete\n    $ make process\n    $ make decisiontree\n\nFor more options, see:\n\n    $ make help\n\n## Processing tasks\n\nAdministrator can also launch the different processing tasks with more options.\n\n`.build/venv/bin/harvest [--force] [--dry-run]`\n\nHarvest metadata from GeoNode, create HazardSet and Layer records.\n\n`.build/venv/bin/download [--title] [--force] [--dry-run]`\n\nDownload raster files in data folder.\n\n`.build/venv/bin/complete [--force] [--dry-run]`\n\nIdentify hazardsets whose layers have been fully downloaded, infer several fields and mark these hazardsets complete.\n\n`.build/venv/bin/process [--hazardset_id ...] [--force] [--dry-run]`\n\nCalculate output from hazardsets and administrative divisions.\n\n`.build/venv/bin/decision_tree [--force] [--dry-run]`\n\nApply the decision tree followed by upscaling on process outputs to get the final relations between administrative divisions and hazard categories.\n\n## Publication of admin database on public site\n\nPublication consist in overwriting the public database with the admin one. This can be done using :\n\n`make publish`\n\nAnd this will execute as follow :\n * Lock the public site in maintenance mode.\n * Store a publication date in the admin database.\n * Backup the admin database in archives folder.\n * Create a new fresh public database.\n * Restore the admin backup into public database.\n * Unlock the public site from maintenance mode.\n\n### Configure admin username/password\n\nBy default, the admin interface authentification file is `/var/www/vhosts/wb-thinkhazard/conf/.htpasswd`. To change the location you can set `AUTHUSERFILE` on the `make modwsgi` command line.\n\nTo create a authentification file `.htpasswd` with `admin` as the initial user :\n\n    $ htpasswd -c .htpasswd admin\n\nIt will prompt for the passwd.\n\nAdd or modify `username2` in the password file `.htpasswd`:\n\n    $ htpasswd .htpasswd username2\n\n### Analytics\n\nIf you want to get some analytics on the website usage (via Google analytics), you can add the tracking code using a analytics variable:\n\n    analytics = UA-75301865-1\n\n### Feedback\n\nThe `feedback_form_url` can be configured in the `local.ini` file.\n\n### Configuration of processing parameters\n\nThe configuration of the threshold, return periods and units for the different hazard types can be done via the thinkhazard\\_processing.yaml.\n\nAfter any modification to this file, next harvesting will delete all layers, hazardsets and processing outputs. This means that next processing task will have to treat all hazardsets and may take a while (close to one hour).\n\n## hazard\\_types\n\nHarvesting and processing configuration for each hazard type. One entry for each hazard type mnemonic.\n\nPossible subkeys include the following:\n\n-   `hazard_type`: Corresponding hazard\\_type value in geonode.\n-   `return_periods`: One entry per hazard level mnemonic with corresponding return periods. Each return period can be a value or a list with minimum and maximum values, example:\n\n    ```yaml\n    return_periods:\n      HIG: [10, 25]\n      MED: 50\n      LOW: [100, 1000]\n    ```\n\n-   `thresholds`: Flexible threshold configuration.\n\n    This can be a simple and global value per hazardtype. Example:\n\n    ```yaml\n    thresholds: 1700\n    ```\n\n    But it can also contain one or many sublevels for complex configurations:\n\n    1.  `global` and `local` entries for corresponding hazardsets.\n    2.  One entry per hazard level mnemonic.\n    3.  One entry per hazard unit from geonode.\n\n    Example:\n\n    ```yaml\n    thresholds:\n      global:\n        HIG:\n          unit1: value1\n          unit2: value2\n        MED:\n          unit1: value1\n          unit2: value2\n        LOW:\n          unit1: value1\n          unit2: value2\n        MASK:\n          unit1: value1\n          unit2: value2\n      local:\n        unit1: value1\n        unit2: value2\n    ```\n\n-   `values`: One entry per hazard level, with list of corresponding values in preprocessed layer. If present, the layer is considered as preprocessed, and the above `thresholds` and `return_periods` are not taken into account. Example:\n\n    ```yaml\n    values:\n      HIG: [103]\n      MED: [102]\n      LOW: [101]\n      VLO: [100, 0]\n    ```\n\n## Translations\n\nThinkHazard! is translated using `Transifex`.\n\n### Workflow ###\n\nWe use lingua to extract translation string from `jinja2` templates.\n\nUse the following command to update the gettext template (`.pot`):\n\n    make extract_messages\n\nNote: this should be done from the production instance ONLY in order to have\nthe up-to-date database strings extracted!\nYou will have to make sure that the `~/.transifexrc` is valid and the\ncredentials correspond to the correct rights.\n\nThen you can push the translation sources to transifex.\n\n    make transifex-push\n\nOnce the translations are OK on Transifex it's possible to pull the translations:\n\n    make transifex-pull\n\nDon't forget to compile the catalog (ie. convert .po to .mo):\n\n    make compile_catalog\n\n### Development\n\nThere are 3 different ways to translate strings in the templates:\n\n - `translate` filter\n\n   This should be used for strings corresponding to enumeration tables in\n   database.\n\n```\n{{ hazard.title | translate }}\n```\n\n - `gettext` method\n\n   To be used for any UI string.\n\n```\n{{gettext('Download PDF')}}\n```\n\n - model class method\n\n   Some model classes have specific method to retrive the value from a field\n   specific to chosen language.\n\n```\n{{ division.translated_name(request.locale_name)}}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGFDRR%2Fthinkhazard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGFDRR%2Fthinkhazard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGFDRR%2Fthinkhazard/lists"}