When it comes to budgets, there’s always interest for analyzing and visualizing the data.

As a way to analyze the way the municipal government of León during the years 2016, 2017 and 2018 (half of it) I wanted to make a spatio-temporal representation of the public investment on infrastructure. Below you can find a brief description of the parts I consider that could be of help to users wanting to build similar map animations.
The visualization was made with QGIS and and FFMPEG, mainly with the former. The data was derived from IMPLAN León (Instituto Municipal de Planeación de León).
First, I duplicated the source point data for having a layer that I could use for the creation of the upper left corner number that shows us the continuosly rising budget figure. Now we should we have the original data layer (1) and the labelling layer (2). Then, I created a new point feature for the labelling layer (2), situating it precisely to the place where I wanted the animated map to capture the rising figure (upper left corner of the canvas).
Then I configured the text and value I wanted to be shown in the upper left corner. This is done by using QGIS’s expression functionalities. So, we’ll use QGIS’s aggregate-expression for creating the running budget figure for the labelling layer (2).
Finally, the expression, including text and value, was:
"'Inversión acumulada en' || '\n' || 'obra pública' || '\n' || format_number(((aggregate('aggregation', 'sum', "monto"/1000000))), 1) || '\n' || 'millones (MXN)'"
The expression above and the following step enables us to see the running number according to the attribute data of our layer of interest. As always, QGIS shows flexibility and enables users to build their maps as envisioned. So, then I configured the labels that I wanted to be seen by filtering the data point that I made earlier. This is done in the styling panel for the labelling layer (2):
Rendering -> Data defined -> Show label -> "Fid = "672""
Here Fid"" is the column that coorresponds to the identifier number of the data points. We’ll filter it to “672” because that is the data point where we want the label to be shown.
The actual map animation was done with the great Time manager -plugin in QGIS. If you haven’t used time manager before, you should read this great blog post by Topi Tjukanov.
For the animation, we need the two layers we previosly worked on. First, we’ll add the labelling layer (2) and then we’ll add the actual data layer (1). With the data layer (1) we’ll just configure it as any other data layer we’ve used for our map animations.
When it comes to the labelling layer (2), we need to add transparency for the data so we’ll just see the the value from the labelling. With the labelling layer (2), we’ll check the “Accumulated” option in the Time manager -plugin’s interface. This is how the expression set earlier will take into account the accumulating sum of the values.
To add the legend to the top-right corner of the video I used FFmpeg by applying the following command on my Linux (Ubuntu) OS.
ffmpeg -i out_simple.mp4 -i legend.png -filter_complex "overlay=main_w-overlay_w-5:5" out_with_legend.mp4
The actual legend.png file created just by composing the legend in QGIS’s Print composer/layout and screeshoting/printing the final result.