TIME Just Named Tomorrow.io a 100 Most Influential Company. Learn More

By Tomorrow.io
Oct 14, 2020· 3 min, 51 sec

Weather Data Is the Answer to Better COVID-19 Policies

Weather conditions affect most of the actions we take. For some, it’s a catalyst, and for others, it has an inhibitory effect.
COVID-19 is no exception. More and more studies show how certain meteorological factors influence the transmission rate of this disease and could impact the trajectory of the pandemic.
One of the most recent studies comes from Turkey and shows a direct link between indicators such as temperature, humidity, wind speed, etc. and the number of new cases in certain cities. This study shows that there is a link of inverse proportionality between temperature, dew point, humidity, and the number of new cases and a link of direct proportionality between wind speed and the number of cases. 
This means that if the temperature, dew point, and humidity decrease or if the wind speed increases then there is a very high chance that the rate of new cases will increase.
Based on this information, we can combine these results with a Weather API in order to create some software solutions to help us in the fight against COVID-19. Using the www.tomorrow.io Weather API, we can combine weather parameters alongside air quality data to better understand the weather conditions at a hyper-local level.
The application we will build is a simple script that, based on a certain location, analyzes the current weather data and informs the user if the values exceed certain thresholds that can cause a faster spread of the virus
Such an application can be used to determine if a particular area where many people go, for example, a beach, is a safe place where people can go.
Humidity has dropped below a certain threshold which can accentuate the rate of spread.

Setting Up the Code

I chose NodeJS as a programming language for this example. The first step is to create a new package manager and install the dependencies.  For this, run the following command.
npm init -y && npm i node-fetch
This command run in a terminal will create a new package.json file without asking any questions and it will install the dependency node-fetch. At the same time, we need to create a free account on Tomorrow.io to get a private key, which we will use to call the API.

Get the Weather Data

Based on the study we discussed at the beginning, the fields of interest are:
  • temperature
  • dewpoint
  • humidity
  • wind_speed
To acquire weather data for these indicators, we’ll do a GET request to the API on route nowcast, which will return data in a 5-minute gap for the next 360 minutes.
In order to take into account the code writing best practices, we will put the code that takes over this data in a function, to which we will send as parameters the private key and the geographic coordinates, namely latitude and longitude.
The function  getWeatherData() will return data in the next format. An array of objects that have as properties the fields we supplied as query parameters in the URL call to the API. 
getWeatherDate() – array of objects like this

Define Safe Levels

Next, we need to define the safe levels for these values. A value that if passed, in a certain direction (higher or lower), might lead to a faster spread of the virus in that area.
const safeLevels = {
  temp: {
    value: 16,
    direction: -1,
  dewpoint: {
    value: 13.5,
    direction: -1,
  humidity: {
    value: 71,
    direction: -1,
  wind_speed: {
    value: 10,
    direction: 1,
I chose these values to be as close as possible to those in the study, but they can be easily modified. The direction variable has the value -1, meaning that the danger zone appears if the value falls below the threshold. If it is 1, then the danger is when the value increases above the threshold.


Finally, we need to call the getWeatherData() function and compare the nowcasting weather data with the safe levels defined.

This writing makes the logic as simple as possible. We could have written another block to go through each entry in the object and thus write only one condition if.
The coordinates 32.0700° N, 34.7633° E that we’ve supplied as arguments, represent the geographical coordinates from Aviv Beach in Israel, but you can easily use coordinates from any other place in the world. 
This script is just a proof of concept. Starting from this base we can create all kinds of more complex applications to help us in the fight with Covid-19. This example can be combined with a geographic map, such as Google Maps, and take coordinates when the user places a marker on the map. Then these coordinates can be used in the created script.

See Tomorrow.io in Action!

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Sign Up for the Tomorrow.io Weather API for Free

Try Now