COVID-19 — Interactive Power BI Map of Total Cases by US State and County

A localized view of the pandemic impacts across the country

Shankar Lakshmanan
Towards Data Science

--

TL;DR Link to the dashboard here

I was talking to my wife about how all counties within the US are reporting COVID-19 cases individually in the news. There are a lot of map trackers for world and US state level reporting but not many maps collated at a county level.

She took it as a challenge and built this amazing publicly-available Power BI interactive dashboard in a single evening!

API and Data Supporting the Dashboard:

Initially, we used this awesome GitHub API credit to the GitHub user JKSenthil: https://github.com/JKSenthil/coronavirus-county-api
who built this python based API which scrapes data from https://coronavirus.1point3acres.com/en

But we ran into some issues when 1point3acres changed their html UI data format which broke the API. I ended up cloning the API and edited it to bring it back to life (which took most of my Sunday). But hey, a Sunday well spent helping the wife. :)

API Forking and Tweaking:

The API uses Selenium WebDriver which runs a headless Chrome that scrapes the web URL, and returns API data as JSON. The API is coded in python and runs on Flask served via gunicorn, deployed and hosted on Heroku. I ran into a few issues:

Issue #1: The API broke because the scraper failed. This stemmed from a change in the source UI format. I was able to get around this by adjusting the scraping logic.

Issue #2: Heroku’s free tier meant I had to restrict gunicorn workers to 1. This won’t be an issue for the app since it’s the only API user requesting data. The requests also only occur once every few hours to refresh the dashboard.

Issue #3: It was taking a while for the API to respond as the scraper had to work through all 3,200+ counties in US to scrape data. I had to bump up the gunicorn timeout expiry to longer than its default.

Closing Thoughts:

All in all, it was a cool experience getting back into web scraping especially with Python and getting my hands dirty with Heroku hosting.

I believe this public map also reveals interesting county level stats and spatial distributions. This is especially pertinent as U.S. COVID-19 cases are increasing. It was also fun helping my wife with a data science project while we are in #quarantine!

If you have any thoughts to share about the topic or questions about the dashboard or tools used, please connect with me on LinkedIn

Here is the link to the interactive dashboard which updates every 24 hours: COVID-19 US Dashboard

--

--

GIS software enthusiast, Spatial Agent who loves solving map based problems, guitarist, a passionate cook and a dad.