Exactly one year ago, I made a PHP script to retrieve weather data from national weather service website (RHMZ (opens new window). I put it to my always-on home server, and set it up to run every hour, which coincides with their updates. Result is a comprehensive data set for several cities in my country, which can be used for additional analysis.
# Background
Why, you may ask? Well, my wife landed a job there at the same time (she is a meteorologist), and she didn’t know how to fetch this data on demand. The Service does have departments which deals with this type of data gathering and storing, but the path to obtaining it was anything but obvious. Since this data can be used for weather forecast verification, we anticipated the need for it later and I went to set up a simple local database.
Script was written in PHP, which emulates a browser request to the page which hosts a table with recent measurements. It then parses this table to gather weather data for several cities and store it in a simple CSV text file. Additional script runs each day and converts this table to Excel format (using excellent PHPExcel (opens new window) library), compresses it and uploads it to a web server for sharing. I used cron to setup these tasks, and even implemented error control (server notifies me by e-mail if something goes wrong, and trust me, it often does).
# Data
We agreed to monitor and retrieve data for following cities in Serbia:
- Belgrade (Beograd)
- Kragujevac
- Niš
- Novi Sad
- Zlatibor
Following weather data was gathered:
- Date/Time (or Timestamp)
- Temperature (in degrees Celsius)
- Atmospheric pressure (in hPa)
- Wind direction
- Wind speed (m/s)
- Relative humidity (%)
- Heat index
- Weather description (clear, cloudy, etc)
# Result
While I waited for some professional to make use of this data, I wondered if I could represent the data from last year for Belgrade on this page. Cue Chart.js (opens new window), simple yet flexible JavaScript charting library. It enables you to visualize data quite easily. Let’s take a look at all temperature values (8791 points!) in Belgrade by timestamps.
Next, from the same dataset, here is the average temperature with maximum and minimum values by days.
Then, aggregation by wind direction, using a pie chart. We can see that the prevailing wind in Belgrade last year was of southeast (SE) direction (also known as Košava).
If you want to know what type of weather was dominant last year in Belgrade, you just have to look at next chart. Apparently clear skies (vedro).
You can download the data here (opens new window), as a simple and self-explanatory CSV file. If you have an idea how to use or analyze it, just go for it 😃
Data courtesy of RHMZ (opens new window)
Photo supplied by Gaga, thanks!