- Blog
- 10.14.2024
- Data Fundamentals
Weather trends in the UK: Spatial analysis with QGIS

It's true - we Brits love to talk about the weather, especially wondering out loud if it's going to rain anytime soon 😀 The reason is that the weather in the UK is highly variable thanks to a set of unique climatic influences caused by its geographical location.
Being right at the intersection of polar and tropical air masses, the UK is regularly hit by extratropical cyclones, and the weather is famously difficult to predict. The North Atlantic Ocean's Gulf Stream moderates temperatures, but the exact position of the jet stream adds to the variability of atmospheric conditions.
For example, as I write, no less than three Atlantic hurricanes (Kirk, Milton, and Leslie) are queued up and heading toward these shores.
Atlantic Tropical Cyclones and Disturbances (7th October,Ā NHC)
In this article, I'll describe a piece of geospatial data engineering involving unstructured data as a source and averaged over multiple years. The goal is to see if and how rainfall patterns have been changing in recent decades.
So where might a data-obsessed weather enthusiast get hold of a whole lot of historical data?
Met Office Hadley Centre and CEDA
The UK'sĀ Met Office Hadley Centre is a prominent entity in the UK involved in the study and analysis of climate and environmental data. TheĀ Centre for Environmental Data Analysis (CEDA) specializes in archiving and distributing environmental data.Ā
These two organizations work closely together: the Hadley Centre providing the data and CEDA providing the infrastructure for storage and access.
For this article, I used precipitation (which usually means rainfall āļø) data supplied by the Hadley Centre as a 1km x 1km raster grid covering the country, year by year, since 1891.
Visualizing rainfall using QGIS
Historical rainfall data is available fromĀ HadUK-Grid on CEDA, and at the time of writing the latest version was 1.3.0.ceda (1836-2023). To download the same data I used, you'll need to sign up for a free account, then follow 1km grid > rainfall > annual > v20240514.
The individual files are held in a specializedĀ unstructured format known asĀ HDF5. It's great for storing time series and gridded (raster) datasets, and it's easy to access usingĀ QGIS.
In QGIS, open a new project and set the CRS toĀ EPSG:27700Ā (OSGB36 / British National Grid). Now, you can add the individual HDF5 files of annual rainfall as layers. Here's the 2023 data, zoomed in to show theĀ Lake District towards the upper left.
rainfall_hadukgrid_uk_1km_ann_202301-202312.nc
In this false color image, the wettest areas show up as dark blue. It's called the Lake District for a reason!
There is significant rainfall variation from year to year, so individual years are not helpful for long-term analysis and trending. Instead, I decided to look at theĀ average rainfall since the turn of the century: the twelve years 2000-2011 compared to the years 2012-2023.
QGIS raster analysis - Cell statistics
Using the same steps again, loadĀ twelveĀ individual years 2000-2011 into QGIS as separate layers. Then, open the Cell Statistics tool from Processing > Toolbox > Raster Analysis > Cell Statistics.
From there:
- Select all 12 input layers
- Calculate the mean
- Choose one as the reference layer (it doesn't matter which - CEDA did a great job keeping them all the same size)
- Set a NoData value of -1 (this doesn't actually happen, thanks again to the high quality source files)
- Output to a new temporary layer
Do this twice, creating two new aggregated layers:
- Mean rainfall 2000-2011
- Mean rainfall 2012-2023
Now, itās time for a little visual disappointment. The two sets of averages are very similar. When rendered using a green-blue pseudocolor range, they are hard to tell apart. The only good way to do so is to flick back and forth between the two images, as you can see in this animated GIF:
Looking closely at the image, you may be able to convince yourself there's a change in the Lake District - it definitely goes a darker blue in the more recent decade, indicating more rain on average. But the rest of the map is harder to interpret. It needs one more data engineering step.
Using the QGIS raster calculator
The HadUK-Grid raster data is very much like a digital image. Every "pixel" has a numeric value between 500 and 5,500, representing the average annual rainfall in millimeters, with a spatial resolution of 1km x 1km.
The raster calculator in QGIS allows you to access these numeric values and perform calculations. It's the spatial equivalent ofĀ "transformation" in ETL.
Open the tool from the Raster > Raster Calculator menu - and consider the following:
- When it comes to the Output Layer - a new GeoTIFF file is a good choice
- DoĀ not create an on-the-fly raster. In my experience this option does not work
- Beyond that, set the Expression like this:
"mean-rainfall-2012-2023@1"Ā -Ā "mean-rainfall-2000-2011@1"
There is only one "band" in both sources, and it's referred to as "@1" in the expression.
After running the calculator, you can add the new "delta" GeoTIFF file as another layer. For this data, the biggest changes are around +500 and -500 mm/year, so a good symbology choice is a red-blue color ramp, with red meaning drier and blue wetter.
With that, an interesting pattern emerges. I was expecting to see a small positive change in rainfall (blue) right across the country, as warmer air can carry more water. But in fact many areas show up as having becomeĀ drier (red) in recent years.
Further reading
Disclaimer: I'm a data geek rather than a climate scientist. But the broad pattern in the UK seems to be that:
- Areas that are already wet (to the west, where the prevailing winds come in from the Atlantic, and over high ground) have become wetter
- Areas that already have lower rainfall (to the east, and in the rain shadow of hills) have become drier. My interpretation is that an overall increase in warmth brings more sunshine and dry weather too
For the curious, theĀ CEDA archives contain over 20 petabytes of data, including temperature and sunshine records, in a wide variety of formats.
- This article from the UK Met Office performed a similar analysis in 2021 and discusses the results
- A statistical investigation intoĀ how far ahead the UK weather forecast is reliable
- A recent study led by the Met Office and Newcastle University toĀ enhance extreme rainfall prediction
Ian Funnell
Data Alchemist
Ian Funnell, Data Alchemist at Matillion, curatesĀ The Data Geek weekly newsletter and manages theĀ Matillion Exchange.
Follow Ian on LinkedIn: https://www.linkedin.com/in/ianfunnell
Featured Resources
ETL and SQL: How They Work Together in Modern Data Integration
Explore how SQL and ETL power modern data workflows, when to use SQL scripts vs ETL tools, and how Matillion blends automation ...
Learn more WhitepapersUnlocking Data Productivity: A DataOps Guide for High-performance Data Teams
Download the DataOps White Paper today and start building data pipelines that are scalable, reliable, and built for success.
Learn more BlogWebhooks and Pushdown Python: Building Interactive and Efficient Data Applications
Part 5 of our blog series demonstrating the art of the possible, using Matillion products and features to build the MatiHelper ...
Learn more
Share: