Nice. We know from the site stats that Scottish stories are popular, as are Raspberry Pi stories. All this needs is a Magnet angle and it would be the Mother lode!
The Gadget Master in question is Sebastian Raubach, and you can find the code, init files, licence and readme files on GitHub.
Where is he getting his weather data from? The answer is openweathermap.org with a button letting you switch between the weather properties displayed.
My new side project is coming along nicely. #raspberrypi powered led matrix showing current weather across #Scotland.
Wind, cloud cover, rain then temperature.
Managed to record this on a day without any rain across Scotland. Those do exist, it seems ????#wip #wednesdayfun pic.twitter.com/RwJf06dyry
— Sebastian Raubach @ ???? ???????????????????????????????????? (@BazRaubach) July 14, 2021
The Pi involved is a Raspberry Pi 3b+. Sebastian notes that other Pis could be used but the Pi Zero was not powerful enough, resulting in a lot of flickering on the display.
There’s also the 5V 4A power supply and a non-latching squid button.
For the script to work, he explains, it works as follows (I quote, from GitHub):
- For each pixel, determine its latitude and longitude. This is done by dividing the horizontal and vertical axes into sections and using the center point for each cell.
- For each pixel, determine whether it’s inside the shape/polygon that should be displayed. This may be a country or any other region. Store the lookup in a file for faster loading times.
- On regular intervals, get weather data for the grid.
To reduce the number of API calls, run an initial call for each 25 square degree (limitation of the API) square inside the area of interest. This will return all cities in that area.
- For each pixel, determine the closest city. If the distance is below a threshold, use that city’s data. Otherwise, send an individual API request for the specific location.
- Display the weather information on the grid using the color gradient and a normalization step to map the value to the corresponding color.
To get the map setup, as well as getting an API key from Openweather, a shapefile defines the boundaries of your area of interest. Scotland-shaped in this case.
Examples are available online, flags Sebastian, and apparently he has already created an equivalent weather map for Germany.
Excellent, whatever the weather may be.
As one of the twitter commenters says, it reminds you of Ceefax!