Skip to content

ttxking/disaster-api

Repository files navigation

MahantapaiSudSanook

Overview

Thailand is one of the country that face many natural disasters. However, these data concerning the topic is not-well format, hard to access, and sparse. Many natural disaster such as landslide, earthquake, fire are neglected. That’s why we come up of a way to collect those datas in the form of API, for easy usage and access

Overall Architect

Screen Shot 2564-12-12 at 21 10 32

Disaster in Thailand API

This API provides information about common natural disaster happening in Thailand. It's separated into 4 categories:

  • Overall monthly natural disaster in each region of Thailand. Raw data provided by Thai Meteorological DepartMent (TMD).
  • Earthquake data in Thailand between 2011 and 2021. Raw data provided by Earthquake Observation Division.
  • Landslide risks area in Thailand. Raw data provided by Department of Mineral Resources (DMR).
  • Rainfall and storm data gathered by our group in Google form.

API features

  1. disaster
    Screen Shot 2564-12-11 at 23 23 25
  2. earthquake
    Screen Shot 2564-12-11 at 23 24 09
  3. landslide
    Screen Shot 2564-12-11 at 23 28 23
  4. survey
    Screen Shot 2564-12-12 at 00 38 59

Data visualization features

  1. Earthquake count by magnitude

    This graph provides the number of earthquake occur compare with the range of earthquake magnitude

  2. Earthquake count by the risk landslide village

    This graph provides the number of earthquake occur compare with risk landslide village

  3. Average Monthly Rainfalls

    This graph provides average rain amount and average rain duration from survey

Prerequisites

  1. Install Node.js (version 3.6 or higher)
  2. Install Python (version 16.13.0 or higher)
  3. Create database in phpMyAdmin (MySQL)
    • Create 4 tables in your database with schema as follows:
      • disaster
        Screen Shot 2564-12-11 at 22 46 14
      • earthquake
        Screen Shot 2564-12-11 at 22 49 52
      • landslide
        Screen Shot 2564-12-11 at 22 50 55
      • survey
        Screen Shot 2564-12-11 at 22 51 34
  4. Add all disasters data from file data to database
    1. Select import
      Screen Shot 2564-12-11 at 22 57 21
    2. Select Choose File
      Screen Shot 2564-12-11 at 22 58 35
    3. Add one number to skip number
      Screen Shot 2564-12-11 at 22 59 29
    4. Select format
      Screen Shot 2564-12-11 at 22 59 40
    5. write column name then click Go
      Screen Shot 2564-12-11 at 22 59 59

Instruction for virtual environment

  1. Install virtual environment
    • Linux/MacOS:
      python3 -m pip install virtualenv
    • Windows:
      python -m pip install virtualenv
  2. Create new virtual environment.
    virtualenv venv
  3. Activate a virtual environment.
    • Linux/MacOS:
      . env/bin/activate
    • Windows:
      env\Scripts\activate

Installation

  1. Clone the repo
    git clone https://github.com/ttxking/disaster-api.git
  2. Change directory
    cd Disaster-API
  3. Install required libraries
    pip install -r requirements.txt
  4. Install OpenAPI-to-GraphQL
    npm install -g openapi-to-graphql-cli@2.5.0
  5. Edit config.py for your phpMyAdmin database
    OPENAPI_AUTOGEN_DIR="autogen"
    DB_HOST="Your database host"
    DB_USER="Your username"
    DB_PASSWD="Your password"
    DB_NAME="Your table name"
    

(back to top)

Usage

  1. Run jar file
    java -jar openapi-generator-cli-5.3.0.jar generate -i openapi/disaster-api.yaml -o autogen -g python-flask
  2. Start the REST API server
    python app.py
  3. Start openapi-to-graphql in another terminal
    openapi-to-graphql --cors -u http://localhost:8080/disaster-api openapi/disaster-api.yaml
  4. Open the index page in http://localhost:8080

Interact with our database

  1. Your can just download openapi-to-graphql and run with this command
    openapi-to-graphql --cors -u http://localhost:8080/disaster-api/ openapi/disaster-api.yaml

But the query it quite slow, you need to wait for 15-30 second

  1. Open the index page in templates\index.html

(back to top)

Contributor

Student ID Name Github E-mail University Faculty Department
6210546714 Anusid Wachiracharoenwong ttxking anusid.w@ku.th Kasetsart University Faculty of Engineering Software and Knowledge Engineering
6210545556 Peerasu Watanasirang BellBoyZz peerasu.w@ku.th Kasetsart University Faculty of Engineering Software and Knowledge Engineering
6210546382 Kittitouch Ingkasompob kinkinkinxd kittitouch.i@ku.th Kasetsart University Faculty of Engineering Software and Knowledge Engineering

(back to top)

About

This repository is part of 01219335 - Data Acquisition and Integration course

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors