Meanings of Taking In the Meteorological Data to "Daily Reports" (Utilizing Weather API)

Monday, October 21, 2013
There are many business operations that depend on the 'weather". As an example to be discussed often, it is like 'purchasing beer'. Sometimes it is called 'weather merchandising', but simply it is business to "purchase" in anticipation of the 'sales'. (Check out events and festivals more) The person in charge decides the quantity of beer to order with considering the weather forecast (even more, events in the region, etc...)

Of course there are many other businesses.
The weather will affect various businesses such as "Weekly planning of construction site", "bad weather measures of agriculture", "Preparing for the event system", "Cancellation correspondence Golf Courses"... Moreover, I heard that "corresponding inquiries in mail-order business" which is indoor businesses, also would be affected by the weather.

The following business flow is 'Daily Sales Report' for restaurant business. It is a typical 'Daily Report type Workflow'.
In this flow, the weather and the temperature of the day are reported along with the sales, so that it would be the basic data for analysis 'Sales variation due to weather'. Most notably, is the point that the weather data is entered automatically in advance. There is no need for the reporter to enter "the weather" and "the temperature". This template would be diverted in the Housekeeping industry, construction, temporary staffing services, as well.

[Daily report flow-weather]

[Daily report flow-weather: '1. Submit Daily Report' screen]

In this Workflow, 'a Reporting task' will be allocated at 8 o'clock in the morning every day, and at the moment the Workflow system will retrieve the weather forecast data from the external server automatically. In this example, inquiring to 'OpenWeatherMap' for the weather data. (Message Throwing Intermediate Event)
To retrieve 'Data for today and tomorrow' (data for 2 days) for Kyoto office (City ID = 1857910), you set a request in the format of "forecast/day? id=1857910&cnt=2".

* http://api.openweathermap.org/data/2.5/forecast/daily?id=1857910&cnt=2

Then,,, it will retrieve 'JSON response' as follows.

{"cod":"200",
  "message":0.011,
  "city":{"id":1857910,"name":"Kyoto",
          "coord":{"lon":135.753845,"lat":35.021069},
          "country":"JP","population":1459640},
  "cnt":2,
  "list":[
    {"dt":1381802400, ★Data acquisition time (UNIX time)★
     "temp":{"day":293.15,"min":291.34,"max":293.15,
             "night":291.34,"eve":292.09,"morn":293.15}, ★Temperature (Kelvin)★
     "pressure":992.09, ★Pressure (hPa)★
     "humidity":100, ★Humidity (%)★
     "weather":[{"id":502,"main":"Rain","description":"heavy intensity rain",
                 "icon":"10d"}],
     "speed":1.96, ★Wind speed (m/s)★
     "deg":39, ★Wind direction (angle: north=0, east=90)★
     "clouds":92, ★Cloud cover (%)★
     "rain":30}, ★Precipitation (mm)★
    {"dt":1381888800,
     "temp":{"day":292.72,"min":287.96,"max":292.72,
             "night":287.96,"eve":291.01,"morn":291.81},
     "pressure":987.8,
     "humidity":86,
     "weather":[{"id":803,"main":"Clouds","description":"broken clouds",
                 "icon":"04d"}],
     "speed":6.15,
     "deg":347,
     "clouds":76}
  ]
}
※ Added "line breaks" and "★ comment ★" for clarity.

Although there are forecast data on 'wind direction' or 'Cloud cover' among them, but you should set only data that you need for this operation, to the Data Items. The following 5 lines are the script for that. (Script Task)

var weatherjson = JSON.parse(data.get("0"));
retVal.put("5", java.lang.String(weatherjson.list[0].weather[0].description));
retVal.put("6", java.math.BigDecimal(weatherjson.list[0].temp.max - 273.15));
retVal.put("7", java.lang.String(weatherjson.list[1].weather[0].description));
retVal.put("8", java.math.BigDecimal(weatherjson.list[1].temp.max - 273.15));

Incidentally, if you set "day of the week information" also, it will help sales analysis.

var daystart = data.get("3").getDay(); //Day of the week
if (daystart == 0) retVal.put("4","Sunday");
if (daystart == 1) retVal.put("4","Monday");
if (daystart == 2) retVal.put("4","Tuesday");
if (daystart == 3) retVal.put("4","Wednesday");
if (daystart == 4) retVal.put("4","Thursday");
if (daystart == 5) retVal.put("4","Friday");
if (daystart == 6) retVal.put("4","Saturday");

By the way, this "Open Weather Map" is a great service that provides weather information around the world for free. Just like Wikipedia, they have an ideology (conviction) of "free use for everyone". (Moreover, you can also get a fairly granular information, such as "measured data" of every three hours.)

By the way, data of a wide range of applications such as "weather data", the government inherently should provide free of charge. However today, both of the "Japan Meteorological Agency"(external organ of the Ministry of Land, Infrastructure, Transport and Tourism " and "Japan Weather Association" do not provide for free. I do hope them accelerating Open Data, Open Government.

In addition, data from 'Open Weather Map' are a little bit different from which Japan Meteorological Agency announces. So, if you need data from JMA, you should be careful. It may be necessary to consider to use a paid service for some companies.

[Process Data Item setting screen]

[Download]
<Similar Models>
<Related Articles>
<<Newly Arrived>>