Making Earthquake PH: Working with Tweets and Maps

15 Jan 2020 | 3 minute read.

The recent disaster in Batangas becuase of the Taal Volcano caused a spew of scientific terms and overflow of science communication to the public. It got me thinking on how we inform the general public regarding these terms and especially during these times where many volcanic earthquakes occur.

As per Gretchen Ho’s tweet above how do we make PHIVOLCS’ tweets into human speak. That’s when I thought of making Earthquake PH.

What is Earthquake PH?

Earthquake PH is a website that gives details about earthquakes in the Philippines in an understandable manner through,descriptions and map visualizations of where earthquakes are. This site was created to make the general public informed about details about earthquakes making information understandable to the normal citizen.

How does Earthquake PH work?

The site uses the Twitter API to scrape the most recent tweets from the PHIVOLCS account every ten minutes. From the recent tweets, we filter them to get tweets specifically regarding earthquake information. Next, we parsed the information from the full text of the Tweet to get the following information using Regular Expressions:

After this, we run the coordinates to a reverse Geocoder to give us an address of where the epicenter of the earthquake is and then save it to our MongoDB database.

Features of Earthquake PH

Earthquake Details

The first feature is a general overview of the details regarding the earthquake. I included the general details from the tweet, a Google Map of the epicenter based on the longitude and latitude given and descriptions about how strong the earthquake was from this website.

Richter magnitude Description Earthquake effect
< 2.0 Micro Micro earthquakes, not felt.
2.0-2.9 Minor Generally not felt, but recorded.
3.0-3.9 Often felt, but rarely causes damage.
4.0-4.9 Light Noticeable shaking of indoor items, rattling noises. Significant damage unlikely.
5.0-5.9 Moderate Can cause major damage to poorly constructed buildings over small regions. At most slight damage to well-designed buildings.
6.0-6.9 Strong Can be destructive in areas up to about 160 kilometres (100 mi) across in populated areas.
7.0-7.9 Major Can cause serious damage over larger areas.
8.0-8.9 Great Can cause serious damage in areas several hundred miles across.
9.0-9.9 Devastating in areas several thousand miles across.
10.0+ Epic Never recorded
Home Screen Detail Page Part 1 Detail Page Part 2

Quake Map

I decided to add another feature which is called the Quake Map the Quake Map visualizes on the screen where the 10 latest earthquakes are, how strong they were and when and where exactly they took place.

Quake Map Page

Technology Used

Now for the technical details, the website is a monolith Express.js application, a MongoDB database from MongoDB Atlas, Several Map and Geocoding APIs and of course Twitter’s Developer API.

In the detail pages of the earthquakes, I used Google’s Map Embed API to visualize the location of the earthquake. On the other hand, I used Leaflet and OpenStreetMaps for the Quake Map since it’s open-source and free unlike Google’s API for multiple markers. Leaflet can also be used for more features down the line.

On updating the data on the site, I just do this by having a Node.js script that runs every 10 minutes and on this file, using the Twitter API, I get the 100 most recent tweets of PHIVOLCS not including RTs then get the information through RegEx, then I check the database if the Tweet ID is already included in the database if it’s not I used LocationIQ’s Reverse Geocoding API to get an address of where the earthquake occurred. Then insert it to the database.

Using the site.

You can visit the site by going to https://earthquakeph.francisoliver.dev/ or by clicking here. The site currently has more than 120 recorded earthquakes and counting.Feel free to suggest new features to the website and how I can improve it.


Share this article:


Related Articles:

Side Projects: Telegram Food Bot using the Zomato API

Date: 19 Oct 2019

In work, we use Telegram as a main communication platform and being in a central business district, there are many...


UAAP Real Time Sentiment Analysis of Fan Tweets

Date: 30 Aug 2019

It is UAAP season once again and this year’s season 82 is hosted by Ateneo it is a good time...


Implementing Dark Mode to Your Jekyll Site

Date: 08 Jul 2019

Jekyll is a static site generator powered by Ruby, that can use both HTML and Markdown for markup and Liquid...