Coder Social home page Coder Social logo

egithinji / powermap-frontend Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 276 KB

power-map.io frontend

Home Page: https://www.power-map.io

License: MIT License

CSS 0.86% HTML 2.78% JavaScript 96.36%
javascript mapbox mapbox-gl twitter twitter-api-v2 twitter-streaming-api

powermap-frontend's Introduction

power-map.io

The back end repo can be found here.

power-map.io was a passion project of mine that displayed a real-time heat map of power outage complaints in Kenya.

It used the Twitter filtered streams API to track public tweets directed at the official Kenya Power Twitter handle (@KenyaPower_Care).

Unfortunately due to the recent changes in Twitter's API pricing, I'm unable to continue pulling this realtime data. In the meantime, the site is displaying complaints captured on May 28th 2023, just a couple days before it lost access to the Twitter Filtered Streams API.

Motivation

I once lived in a neighbourhood with very frequent power outages, but there was no way of reliably determining whether the outages were worse in my neighbourhood than others.

Whenever the power would go out, I would often go to Twitter and check for power outage complaints directed at @KenyaPower_Care to get a sense of whether other people were also experiencing power outages.

That's what gave birth to the idea of fetching this data via Twitter's Filtered Streams API, and I thought "Wouldn't it be cool if we could see the complaints pop up in realtime on a heat map?"

How it worked

Twitter doesn't provide geodata pertaining to a tweet, so how was I able to know where on the heat map to generate a point?

I first manually created about 200 geojson polygons of neighborhoods/areas in Kenya using https://geojson.io/. I then associated each polygon with colloquial words that Kenyans typically use when referring to the area. For example the polygon for Westlands would be associated not just with "westlands", but also "westie".

I connected to Twitter's Filtered Streams API to capture all tweets directed at @KenyaPower_Care. As expected, nearly all tweets directed at their Twitter handle were people reporting a power outage and mentioning the area affected.

I did some simple parsing of each tweet to see whether it mentioned an area description in my database. If it did, I then generated a random point within that area's polygon.

It turned out that generating a random point within a polygon wasn't as straightforward as I had thought. The method I settled on involved three steps:

For the actual heat map, I used Mapbox. I really liked their dark mode heat map design and they have a free tier that was generous enough for my use case.

Next steps

This was a really fun project to work on. It was really satisfying seeing everything come together and seeing the dots pop up on the heat map in realtime, and actually being able to compare the severity of power outages per neighborhood.

My goal was to collect power outage complaint data over a significant period of time, and then develop a tool for doing rich analysis on this data.

Now that power-map.io has been cut off from its main source of data, I'm thinking of either pivoting the site to something slightly different, or finding other ways of capturing the same information.

Let me know in the issues if you have any ideas!

powermap-frontend's People

Contributors

egithinji avatar

Stargazers

 avatar

powermap-frontend's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.