 Hello, in this video I'm going to explain how to create an animated coroplete map in QGIS using the temporal controller. This video is part of the summer course at IHE Delft on creating data visualizations with graphs, maps and animations. You can find the free tutorial also at gisopencourseware.org. You can find the link in the description of this video. First we need a world map with country boundaries. Instead of using natural earth, this time we'll use the official UN world map. We can add it as an ArcGIS REST server. In the browser panel, configure the connection. The URL is also provided in the description of this video. Expand UN boundaries and then expand base layers. There you find country areas and drag the polygon layer to the map canvas. This is an online layer and it will take some time for it to load. When it's loaded we're going to export it to a geopackage to have it as a local file. Let's call the geopackage access to water and let's call the layer country boundaries. Click OK and now you can remove the online layer from the layers panel. For this exercise we're going to use data from our world in data.org. It's a great resource to find all kinds of data sets for sustainable development. If you go to the about page you will learn more about this initiative. The search box is very useful and we're going to search for improved water source and we're looking for the data set of the number of people without access to an improved water source. It is explained here what is meant with improved drinking water sources. This includes pipe water on premises, piped household water connection located inside the user's dwelling plot or yard and other improved drinking water sources such as public taps or standpipes, tube wells or boreholes, protected dug wells, protected springs and rainwater collection. Here we already see nice maps with the changes through time and you can click on table to see what kind of tabular data is available, which sources were used and a download tab where we can download the full CSV for playing around ourselves with this data. With CSV files it is good practice to always open it with a text editor to see the contents. Here we open it in notepad and we can see that there is a country, a code of three characters a year and the amount of people without access to improved water sources. After downloading we can drag the CSV into our geo package. Then we can drag it to the map canvas and we can open the attribute table to see if this import went well. And there we indeed see that this looks great. But for our calculation we also need population statistics because we need to normalize later. So we search in our world in data for population and we download population since 10,000 BC and we also download that full CSV to our hard drive. Let's check the data. This also has the country name, a three letter code, the year and the amount of people living in that year in that country. And we see that it covers the years that we need for our other data set. So we can calculate the percentage of people that have not access to improved water resources. So we can also import that in the geo package and we can save the whole project in the geo package before we continue. Let's call it access to water. We need to join the two tables and they have in common that they both have a field with the country code and the year. But we need to join based on the two fields and therefore we need to concatenate these. So in the field calculator create a new field code here as a text and concatenate code with year. So we will have the three letter code and the year. Check the result. Here indeed we have the new field and save the attribute table. Now we are going to repeat that for the table with the number without improved water so we can later join them. So here we create exactly the same field, code year as text and we concatenate code to year. The preview looks good. Click OK and there we see the three letter code and the year. This data set goes from 2000 to 2020. So now we can join both tables. Go to the layer properties and to the joins tab click the plus and there join the population table with code year in both join and target fields. And choose for the joint field population and remove population underscore from the prefix. Verify here that the settings are correct and click OK. Now we can see the result in the attribute table. We see now that we have the number of people without access to improved water resources and the total population in that year. Now we can calculate the percentage. Go to the field calculator and give the output field name percentage, which is a decimal number. Start with the bracket from fields and values double click on the number of people without divided by the total population and close the bracket and multiply it with 100 to get the percentage. The preview looks good. Click OK to apply it and here we see the results because we're going to use this in the temporal controller. Later we need to fix another thing here in the attribute table. The year field is a string but needs to be converted to date format. So we create a new field. We call it date and we give it the date field type. Only in that way the temporal controller will recognize it. We use the to date function to convert our string to a date. So we add the year string from the year field and we indicate the format, which is year, y, y, y, y. But it should be a string, so in single quotes and we close the bracket. And here in the preview we see that it's date format with the date added to it. And if we look at the results we see here that it added first of January of every year, which will work in the temporal controller. So I took it off editing and saved the results. Now we need to join those attributes to the countries. Because we have multiple years per country polygon, we have to use the join attributes by field value tool. As input layer we use the country boundaries, table field that will be joined ISO3CD. The common field in number without improved water is code and we're going to join percentage and date. And make sure to change here the join type to one too many. We save the result to a geo package, the existing one, and add as a layer name percentage without improved water. Now we run the tool and it added the layer. Let's check the result in the attribute table. And now we see that we have the date and the percentage in the last two fields. And that's exactly what we need for the animation. Now all the country polygons with different years are on top of each other. So we're going to set a filter to only look at one year before we're going to style it. In the layer properties you can do that in the query builder under source. Choose the date field and I click all to get all the dates and I create here an expression date equals and then on the year 2000. This will make sure that we're only looking at the polygons of the year 2000. And we're going to use that for the styling. Note that in the year 2000 some countries have missing data. If I hover my mouse over the filter it will show the expression. Now let's open the layer styling panel. Since this is a coroplete map we're going to change it to the graduated render. Percentage is the field that we use as value. Click classify to see the default ramp. By default it will use quantile but let's have a look at the histogram and we see that it has a very skewed distribution. So let's try natural breaks. And we also need a bit more classes. Let's change it to 7. And let's choose another ramp. From yellow via orange to red. So the more red the worse the condition. Since the data is very skewed I'm going to change the values here to the same ones that our world in data used in their visualization. Which I think reflects quite well the different ranges in the skewed distribution. You can simply edit the lower and upper value of the range and the legend is also adapted. Make sure that the classes are unselected and click on the color bar at symbol. Go to simple fill and here we change the stroke color to a gray. It's for the boundaries. Also make the stroke width smaller to 0.06 millimeters. As you see we have countries with no data in that year. So we're going to also use the country boundaries and make sure that it will be below with a gray value for countries that have no data. So we change the simple fill color to gray. And here we use 235, 235, 235. And you make sure that the stroke color is exactly the same as the stroke color that we had for the other layer. And also make the stroke width the same. Now as we can see we have a nice gray for the countries with no data and the borders are similar. Now also change the projection from the pseudo-mercator to the equal earth projection and save the project. Now the styling is complete we can remove the filter. Click clear and click OK. Now all the patterns are again drawn on top of each other for the different years. So it's time to start the temporal controller. Click right and go to properties and there go to the tab temporal in the layer properties. Activate the dynamic temporal control and change it to single field with date time. Because we have this date field that we indicate there and the event duration is one year that's the time step. Click OK to apply and now you see the clock symbol at the layer which means we can use the temporal controller. In the toolbar there's also a clock to activate the temporal controller panel. And if we click the play button we can then set the full range and make sure to set the step to one year. So now every time step is one year and we can see the animation. Now we need to add some map elements and we use the decorations for that. Let's first add a title. Let's call it share of the population without access to improved water source. Change the font to Calibri, Bold and size 16 and click OK. Change the background bar color to white. Keep the rest as default. Now we have the title on top of the map and it depends how we pan the map on what distance it is from the map. So if we want to design our map here for the animation that we're going to export we can play with the size of the panel of the temporal controller and the layer styling panel to get the right shape of our map canvas for the animation. Note that we are not interested in Antarctica so I have moved it in such a way that we get a nice coverage of the rest of the globe and the title. Let's add a legend in a print layout and make a screenshot that we can then use as a decorator. In the print layout we only add the legend and we uncheck the auto update box so we can add it and remove the layers that we don't need. Change the title and we use here percentage of population. Let's edit the last class and click somewhere in the blank to remove the handles and then we make a screenshot. Use Windows button shift S on Windows 11 and then drag a rectangle around the legend. Click on it and then click the save button to save it to a file. Save it to legend.png. Close the print layout and now go to view decorations image to add the legend as an image. Browse to the image, modify the size. 40 millimeters will do and we use a margin of 20 millimeters in the horizontal. We still need to add the data credits and the author so we go back to the decorations and to the copyright label. We enable the copyright label and we replace the text. Use the text that was provided by our world in data.org as the reference data. Keep it at bottom right and use a margin of 10 millimeter from the edge in horizontal. Change the font. I'm going to use Calibri, Italic and we keep the rest default. Click OK to apply. We still need to add a timer and one way of doing that is to add an expression to the title. So I want to see in and then the year of the time step. As an expression, we need to use format date to create a format in a year of the variable that represents the time step. And the variable is map start time. This is the updated time that is given for every time step. And I want to format it as year. So I do why, why, why, why in string. And then close the bracket and we see here in the preview that it looks correct. Click OK and it has added the expression. And then click OK and there we see it in the title. Now let's run the animation and see if the timer works. Yes, it's counting the years. So we're ready to export this as an animation and from QGIS you can export the frames. Then in GIMP we're going to create an animated GIF. To export the frames, click the disk button and then browse to the folder where you want to save it. Let's create a folder frames. Make sure it uses the map canvas extent and click save. Now for every year it will save a PNG file. When the export is complete, we're going to load the PNG frames in GIMP. GIMP is the open source equivalent of Photoshop and you can download it free from GIMP.org. When the export is completed we go to GIMP and there we can open the frames as layers, which means that they are all loaded in GIMP as layers on top of each other. That takes a while but when it's finished you go to filters, animation, and there you choose optimize for GIF. And now we can save this as an animated GIF by going to file, export as, browse to the folder and let's call it animation.gif. Based on the file extension it knows that we want a GIF, but we need to indicate that it's an animation. Remove the comment, check the box for as animation, change the delay to 300 milliseconds, and apply this for all frames. This gives a good speed for our animation. Click export and here is our animation. So in this video you've learned how to create an animation for a corrupt plasma.