Exploring spatiotemporal vector data using Time Manager
In this recipe, we will look at exploring spatiotemporal vector data using the Time Manager plugin. We'll use event data from the
ACLED (Armed Conflict Location and Event Data Project) at http://www.acleddata.com/about-acled/.
To follow this recipe, please load ACLED_africa_fatalities_dec2013.shp. The layer style that you will see in the following screenshots consists of a simple circle marker at 50% transparency with the data-defined size set to the number of fatalities of the incident. (You can read more about styling in Chapter 10, Cartography Tips, and Learning QGIS book by Packt Publishing.) If you want some additional geographic context, you can also load NE_africa.shp, which contains the outline of Africa.
Once the data is loaded, all event positions will be displayed. The default way to filter the events, for example, to only see the events from December 1, is to use Layer | Query and enter a filter expression or query, such as the following:
- It's easy to see that updating this query manually for each day will not be a very convenient way to explore spatiotemporal data. Therefore, we will use the Time Manager plugin (installed using Plugin Manager).
- The Time Manager panel will be added to the bottom of the QGIS window once the plugin is installed. Click on the Settings button to open the Time manager settings dialog. We can configure Time Manager here.
- Click on Add Layer to open the Select layer and column(s) dialog.
- Select the ACLED_africa_fatalities_dec2013 layer and EVENT_DATE as starting time and then click on OK to add the event point layer to the list of managed layers, as shown in the following screenshot:
Note
Optionally, you can enable display frame start time on map to add a small label with the corresponding timestamp to the rendered map.
- Click on OK when you are done. At this point, Time Manager applies the temporal filter to the dataset, so this can take some time depending on the size of the dataset used.
- By default, after the first layer has been added, Time Manager will display all the events that occurred during the first day of the dataset. It is easy to adjust the filter by changing the Time frame size settings. You can increase the number of days that should be displayed or change to one of the other time units, including seconds, minutes, hours, weeks, and months, as shown in the following screenshot:
- Once you are happy with the settings, you have multiple options to navigate through time:
- Click on the play button in the bottom-left corner of the Time Manager panel to start an automatic animation
- Move the time slider to the center of the panel like you would do to navigate within a video or music player application
- Click on the forward or backward button on either side of the slider to advance or go back by one time frame
- Of course, you can also edit the Time frame start setting directly
For performance reasons, Time Manager relies on the layer query/filter expression capability of QGIS. This comes with the following limitations:
- Time Manager can only be used with data sources that support layer queries or filter expressions. Most notably, this means that it cannot be used with delimited text layers.
- As the layer queries or filter expressions have to work with strings, it has to be possible to order the date-time values correctly using text sort. Therefore, the values have to be stored in one of the following formats:
Note
If your data uses a different format, which is ordered correctly as well, you can add it to timevectorlayer.py or change the format using Field Calculator.
- The following recipes will show you how to create videos and more sophisticated time-dependent styles using Time Manager.