Geogiffery in a nutshell — introduction to QGIS Time Manager

Topi Tjukanov
10 min readDec 26, 2017

--

Geography + animated gifs =geogiffery

I have been posting a looooot of map animated maps lately on Twitter and quite often people ask me how can they make their own animations. I bet there are lot of ways to achieve similar results, but I am using QGIS + Time Manager plugin. I wanted to make a simple tutorial for beginners on how to get in to the fascinating world of geogiffery. As far as I know, the word geogiffery was first introduced to mankind by the great geogifferer Alasdair Rae.

To explain it as simply as possible: to produce animations like the one below, QGIS Time Manager allows you to export several individual frames (map images) at a certain time interval from QGIS which can then combined into one animation.

Bubbles? Nope, my animation with QGIS Time Manager. 5 hours of train GPS points in Finland.

First of all, huge thanks goes to Anita Graser and others who have been actively developing the great plugin. You can read more about the plugin and different use cases here or here and if you find this tutorial long and complicated, you can always check YouTube, where you can find a few good Time Manager tutorials.

Assumptions I am making in this tutorial are that you have QGIS installed on your computer and some prior knowledge in using it (adding layers, changing styles and working with projections). So not much.

Let’s get started!

About dates (not the fruit) and times

The QGIS Time Manager Help dialog opens up the following text:

The aim of Time Manager plugin for QGIS is to provide comfortable browsing through temporal geodata. A dock widget provides a time slider and a configuration dialog for your layers to manage.

Time Manager filters your vector datasets and displays only features with timestamps in the user specified time frame. Timestamps have to be in one of the following formats:

YYYY-MM-DD HH:MM:SS.ssssss

YYYY-MM-DD HH:MM:SS

YYYY-MM-DD HH:MM

YYYY-MM-DD

YYYY/MM/DD HH:MM:SS.ssssss

YYYY/MM/DD HH:MM:SS

YYYY/MM/DD HH:MM

YYYY/MM/DD

DD.MM.YYYY HH:MM:SS.ssssss

DD.MM.YYYY HH:MM:SS

DD.MM.YYYY HH:MM

DD.MM.YYYY

DD-MM-YYYY HH:MM:SS.ssssss

DD-MM-YYYY HH:MM:SS

DD-MM-YYYY HH:MM

DD-MM-YYYY

DD/MM/YYYY HH:MM:SS.ssssss

DD/MM/YYYY HH:MM:SS

DD/MM/YYYY HH:MM

DD/MM/YYYY

That seems like a lot of time formats! But it is important to note that in your data they have to be exactly like one of those formats and every feature has to have a value in their time column for the animation to work properly.

For example in Finland it’s typical to write dates in the format D.M.YYYY if the day and month are single digit numbers. Also if you have data from several years, note that simple 2015 doesn’t work as your time value, but you have to modify it to something else, like 2015–01–01. Neither does American 5pm work as a time format.

If your data doesn’t use one of the accepted formats listed earlier, you have to modify the data by hand. You can do this with Notepad++, Excel, QGIS Table Manager, SQL or whatever is the most comfortable tool for you to use. I’m not going to go in to more detail on how to modify your data, but a general guideline is that if your data doesn’t work immediately with Time Manager, your date format is wrong, or you have some features with missing attributes.

General overview on Time Manager

Like all the other plugins in QGIS, you can install the Time Manager from the Plugins tab on your QGIS main window. Once you have it installed, you can open it up from same tab. Time Manager dock widget should appear on the bottom of your QGIS canvas.

Dock widget

The dock widget has a play button and a button where you can turn Time Manager on and off. Time frame size defines how long one frame is and that is very important in defining how many frames your animation will be when it’s exported. Dock widget also has a setting where you can adjust how long is one frame and a button for exporting the frames.

By clicking the Settings button, the following window opens:

It might look a bit confusing at first look, but fear not! It’s eventually super simple. To highlight few important parts from the settings dialog, on the top right you can see the Add layer button. That allows you to add data for Time Manager to use, once you have the data added to your QGIS project. Secondly the Show frame for option allows you to change for how long a frame is shown in QGIS. But it’s good to note that this doesn’t affect your final animation, but only the animation shown in QGIS if you browse your data there. From Time display options you can adjust in what way time is shown on the animation.

Like you can see in my example in the beginning of this tutorial, I used a different font, increased the font size, displayed only %H:%M and placed it NE of the frame. Note that you can also write your own text in that text box, like “Train movement in Finland %H:%M”

Let’s make a geogif already!

In this tutorial I am using a dataset with train GPS locations and speeds. An API offering that data was recently opened in Finland so I had to test it out immediately. It’s a similar dataset as I used in the example shown earlier in this blog post.

You can download sample data for this tutorial here. If you want to get your own data from the API, you can use my Python script. Full description of the API can be found via this link.

As our sample data is neatly in a csv file, we can add it to QGIS by clicking the comma symbol on your QGIS left sidebar. Once you click that and browse to your file on your computer, you should see the following dialog:

As I have given the names lon & lat to the data columns with coordinates, QGIS automatically detects them and you only have to click OK. After few seconds (depending on the machine you are using), you should see the data on your canvas. Don’t care about the warning about unknown CRS, as it guesses it correctlu in this case and the data is in EPSG:4326.

I am aware that importing the data to PostGIS would make the animation run much more smoothly, but just to keep this tutorial as simple as possible, we are just using the a local file instead of a database. But note, that if you have any possibility to use PostGIS, please do! Especially when you try to make an animation with more than million rows of data without PostGIS it starts to become quite painful and even impossible.

Once you have the points on your canvas, you can right click the layer and choose Save as. I recommend saving the data into a geopackage. In the Save as dialog, you can leave out the lat & lon attributes to make the file as small as possible. I also recommend changing the coordinate system to EPSG:3067 as that is the official Finnish national coordinate system. Remember also to change the project to use the same coordinate system from the bottom right corner of your QGIS window.

Once you have your geopackage ready, you can then remove the csv file from your canvas. Then you can add the data to Time Manager.

In Time Manager settings go click Add Layer and select your file. Then select which column has the time attribute, which is column named time (obviously..) in our test data. Click OK and QGIS then automatically detects the time format. QGIS loads the data for a while and then everything disappears from your screen. But don’t worry, because this is just the first frame of your animation! You can use the slider on the toolbar to browse through the file. There are few odd points in the beginning of the file, but once you browse few minutes forward using the slider on the Time Manager dock, you notice that the points start to move like trains!

You can then add a background map and do styling with your layer from Layer properties (more about that later) and once you are pleased with your results, you can move on to exporting the frames.

From canvas to frames and from frames into an animation

The export dialog opens when you click Export frames, from your Time Manager dock widget. You will see the following image:

Export dialog

The time how long the export process takes, depends on your machine performance, file format and the settings you have chosen. I am usually making animations with something between 100 to 500 frames. That would mean in this case using two minutes per frame (the csv I provided has around eight hours of data → 1H = 60 min → 2 min per frame = 60 * 8 = 480 frames). This is defined by Time frame size in the dock widget.

Once you have exported your individual frames, you can make an animation out of them. Here’s what I wrote in one of my previous blog posts on how to create an animation in GIMP:

You should open up all the frames with the GIMP Open as Layers option from the main file menu. Browse to the folder where you have exported all the Time Manager frames and select all of them. GIMP creates a new project with all of your images as layers.

If you have a lot of frames, say + 500, might be a good idea to optimize the file a bit. Go to filters → Animation → Optimize (for GIF) and GIMP will automatically reduce the resulting file size. This is optional and of course depends on how you are going to use the final file.

To export the image, just go to File → Export as in GIMP and select GIF as the final format. From the GIF export options you can choose whatever delay you think works best on your visual. Usually with these animations, I have used something around 100 milliseconds.

If you have the possibility to use Photoshop or GIMP to stitch the frames into an animation, that’s great, but if you don’t, no reason to worry! There are plenty of decent online tools where you can upload your frames, adjust the settings on your browser and then download the animation when ready. One service which allows you to do this is Ezgif or Gifmaker.

John Wiseman commented on Twitter: “ Might be worth mentioning gifsicle (`brew install gifsicle` on OS X) as a handy command line tool for creating optimized gifs.”

So there you have it! The whole process of generating an animated map. I think anyone with basic knowledge in QGIS and working data is easily able to use Time Manager.

But what if you want to make your animation look sexy?

Making your data look sexy

Recently when I posted the train animation showed in the beginning of this blog post to Twitter, the following comment which I got was very delightful:

So now you know how to technically make an animated map, but what makes a map look good at the end of the day? Of course there’s not an simple answer to this and people prefer different things, but I can give a few pointers which I have used in my animations.

  • Less is more. Do you really need a background map? Do you really need labels? As you are making an animation, there’s a lot of things happening on the map, so try to only show what’s really relevant.
This map only shows land and oceans. Data from Natural Earth.
  • Use dynamic styling. In my train animation I used the train speed attribute to define the circle size. You can do this by going to Layer properties and clicking the small black arrow on the right side of Size and select Edit. From there you can test out different values for point size, label positions or whatever you think you can use values dynamically from the data.
This is how I defined train marker size in the train animation

Example of this can be seen at the beginning of the blog post and here:

Point size has been defined in this visualization as cars per hour / 1000 so it changes constantly through time
  • Duplicate your Time Manager layer. This was one trick I have been using in several of my animations to create tracks for the moving points. You can do this simply by duplicating your layer in QGIS and adding it again to Time Manager. Then use different styling for the two layers and you will get a nice trailing effect like you can see below.
The trails show really well where the ships have been moving
  • Be experimental with colors and feature blending modes. There are several good color palette tools online (beyond the excellent Colorbrewer). Sometimes it’s surprising how well a bit more extreme color selections work in an animation. Also a great way to work with overlapping features, is to use transparency and different feature blending modes QGIS has to offer.
The colors might be weird, but together they work pretty well
  • +1: As you can see from all of the examples above, black background is always a good choice.

I hope you enjoyed reading this blog post. If you post any animations based on this tutorial to Twitter, please let me know!

Happy geogiffin’!

--

--