You are on page 1of 13

Author

Ujaval Gandhi

Follow @spatialthoughts

Check out more QGIS learning materials, including free full-length QGIS courses from Spatial Thoughts
Academy (https://spatialthoughts.com/resources).

Subscribe to my list

Email address

Subscribe

Change Language

English

Animating Time Series Data (QGIS3)


Time is an important component of many spatial datasets. Along with location information, time providers an-
other 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 Tem-
poral controler. Temporal controler allows you to view and export ‘slices’ of data between certain time inter-
vals that can be combined into animations.

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

Overview of the task


We will take a point layer of maritime piracy incidents, create a heatmap visualization and create an animation
of how the piracy hot-spots have changed over past 2 decades.

Other skills you will learn


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
(https://msi.nga.mil/NGAPortal/MSI.portal) provides a shape le of all incidencts of maritine piracy in the form
on Anti-shipping Activity Messages (https://msi.nga.mil/Piracy). Download the Arc Shape le
(https://msi.nga.mil/api/publications/download?key=16920958/SFH00000/ASAM_shp.zip&type=download) ver-
sion of the database.

Natural Earth (http://naturalearthdata.com) has several global vector layers. Download the 10m Physical Vec-
tors - Land
(https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_land.zip)
containing Land polygons.

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

ASAM_shp.zip (http://www.qgistutorials.com/downloads/ASAM_shp.zip)

ne_10m_land.zip (http://www.qgistutorials.com/downloads/ne_10m_land.zip)

Data Source: [NGA_MSI] (../credits.html#nga-msi) [NATURALEARTH] (../credits.html#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 le. Expand it and select the asam_data_download/ASAM_events.shp layer and drag it on to
the canvas.

2. Once the layer is loaded, you can see the individual points representing incidents of piracy locations.
There are thousands of incidents and it is di cult 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.
3. In the renderer selection drop-down, select Heatmap renderer. Next, select the Viridis color ramp
from the Color ramp selector.

4. Adjust the Radius value to 5.0 . At the bottom, expand the Layer Rendering section and adjust the Opa-
city to 75.0% . This gives a nice visual e ect of the hotspots with the land layer below.
5. Now let’s animate this data to show the yearly map of piracy incidents. Right click on ASAM_event layer,
and choose Properties .

6. In the Layer properties dialog box, select the Temporal tab and enable it by clicking the checkbox..
7. The source data contains an attribute dateofocc - representing the date on which the incident took
place. This is the eld 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.
8. Now a clock symbol will appear next to the layer name. Click on the Temporal Control Panel (Clock
icon) from Map Navigation Toolbar.

9. 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.
10. Now you are ready to preview the animation. Set the Step as 1 Year then click the Play button to start
the animation.

Note
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.

11. It would be helpful to also display a label showing the current time frame on the map. We can do that us-
ing the built in Title decoration. Go to View ‣ Decorations ‣ Title Label.
12. Click the checkbox to enable it and click Insert an Expression button and enter the following expres-
sion 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
(https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/functions_list.html#format-
date) for details on various supported formatting options for the timestamp.
format_date(@map_start_time, 'yyyy')

13. Select font size as 25 , set background bar colour as White and set the transparency to 50% . In Place-
ment choose Bottom Right . Now click Ok.
14. 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.

15. Click on the ... Output directory to choose the directory at which the images will be saved.
16. Under the Extent select the Calculate from Layer ‣ ne_10_land layer. Click Save.
17. Once the export nishes, you will see PNG images for each year (total 18 images) in the output directory.
18. Now let’s create an animated GIF from these images. There are many options for creating animations
from individual image frames. I like ezgif (https://ezgif.com/maker) for an easy and online tool. Visit the
site and click Choose Files and select all the .png les. Once selected, click the Upload and make a GIF!
button. Once created, you can download the GIF using the Save button.

19 Comments QGIS Tutorials and Tips 🔒 Disqus' Privacy Policy 


1 Login

 Recommend 7 t Tweet f Share Sort by Best

You might also like