Animating Time Series Data (QGIS3)

Time is an important component of many spatial datasets. Along with location information, time provides another dimension for analysis and visualization of data. If you are working with dataset that contains timestamps or have observations recorded at multiple time-steps, you can easily visualize it using the Temporal controler. Temporal controler allows you to view and export ‚slices‘ of data between certain time intervals that can be combined into animations.

Bemerkung

Temporal Controller is available from QGIS 3.14 onwards. For older versions of QGIS, the Time Manager plugin provides a similar functionality.

Überblick über die Aufgabe

Wir werden eine punktuelle Schicht von Piraterievorfällen auf See erstellen, eine Heatmap-Visualisierung erstellen und eine Animation erstellen, wie sich die Hotspots der Piraterie in den letzten 2 Jahrzehnten verändert haben.

Andere Fähigkeiten, die Sie lernen werden

  • Using the Heatmap renderer for quick visualization of dense point data

  • Creating and using custom map projections

Get the data

National Geospatial-Intelligence Agency’s Maritime Safety Information portal provides a shapefile of all incidencts of maritime piracy in the form on Anti-shipping Activity Messages. Download the Arc Shape file version of the database.

Natural Earth has several global vector layers. Download the 10m Physical Vectors - Land containing Land polygons.

For convenience, you may directly download a copy of the above layers from below:

ASAM_shp.zip

ne_10m_land.zip

Data Source: [NGA_MSI] [NATURALEARTH]

Procedure

  1. In the QGIS Browser Panel, locate the directory where you saved your downloaded data. Expand the ne_10m_land.zip and select the ne_10m_land.shp layer. Drag the layer to the canvas. Next, locate the ASAM_shp.zip file. Expand it and select the asam_data_download/ASAM_events.shp layer and drag it on to the canvas.

../../_images/1.png
  1. Once the layer is loaded, you can see the individual points representing incidents of piracy locations. There are thousands of incidents and it is difficult to determine with more piracy. Rather than individual points, a better way to visualize this data is through a heatmap. Select the ASAM_events layers and click the Open the layer Styling Panel button in the Layers panel. Click the Single symbol drop-down.

../../_images/2.png
  1. In the renderer selection drop-down, select Heatmap renderer. Next, select the Viridis color ramp from the Color ramp selector.

../../_images/3.png
  1. Adjust the Radius value to 5.0. At the bottom, expand the Layer Rendering section and adjust the Opacity to 75.0%. This gives a nice visual effect of the hotspots with the land layer below.

../../_images/4.png
  1. Now let’s animate this data to show the yearly map of piracy incidents. Right click on ASAM_event layer, and choose Properties.

../../_images/5.png
  1. In the Layer properties dialog box, select the Temporal tab and enable it by clicking the checkbox..

../../_images/6.png
  1. The source data contains an attribute dateofocc - representing the date on which the incident took place. This is the field that will be used to determine the points that are rendered for each time period. Select Single Field with Data/Time in Configuration Drop down menu, dateofocc as Field.

../../_images/7.png
  1. Now a clock symbol will appear next to the layer name. Click on the Temporal Control Panel (Clock icon) from Map Navigation Toolbar.

../../_images/8.png
  1. Click on the Animated Temporal Navigation (play icon) to activate the animation controls. Click the Set to Full Range (refresh icon) next to Range to automatically set the time range to the match the dataset.

../../_images/9.png
  1. Now you are ready to preview the animation. Set the Step as 1 Year then click the Play button to start the animation.

../../_images/102.png

Bemerkung

If the animation is too fast, you can adjust the frame rate by clicking Temporal Settings (yellow gear icon) at top-right corner of Temporal Controller panel. Decreasing the the frame rate (frames per second) will slow down the animation.

  1. It would be helpful to also display a label showing the current time frame on the map. We can do that using the built in Title decoration. Go to View ‣ Decorations ‣ Title Label.

../../_images/112.png
  1. Click the checkbox to enable it and click Insert an Expression button and enter the following expression to display the year. Here the variable @map_start_time contains the timestamp of the current time slice being displayed. So we can use that timestamp and format it to display year of occurrence. See the QGIS Documentation for details on various supported formatting options for the timestamp.

format_date(@map_start_time, 'yyyy')
../../_images/122.png
  1. Select font size as 25, set background bar colour as White and set the transparency to 50%. In Placement choose Bottom Right. Now click Ok.

../../_images/131.png
  1. Once the parameters are set accordingly, the year will display as shown. To export these as images and convert them as GIF select the Export Animation (save icon) in the Temporal control window.

../../_images/141.png
  1. Click on the ... Output directory to choose the directory at which the images will be saved.

../../_images/151.png
  1. Under the Extent select the Calculate from Layer ‣ ne_10_land layer. Click Save.

../../_images/161.png
  1. Once the export finishes, you will see PNG images for each year (total 18 images) in the output directory.

../../_images/171.png
  1. Now let’s create an animated GIF from these images. There are many options for creating animations from individual image frames. I like ezgif for an easy and online tool. Visit the site and click Choose Files and select all the .png files. Once selected, click the Upload and make a GIF! button. Once created, you can download the GIF using the Save button.

../../_images/18.gif

If you want to give feedback or share your experience with this tutorial, please comment below. (requires GitHub account)