Animar Datos de Series de Tiempo (QGIS3)¶
Time is an important component of many spatial datasets. Along with location information, time providers 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.
Nota
Temporal Controller is available from QGIS 3.14 onwards. For older versions of QGIS, the Time Manager plugin provides a similar functionality.
Vista general de la tarea¶
Tomaremos una capa de punto de incidentes de piratería marítima, crearemos una visualización de mapa de calor y crearemos una animación de como han cambiado los puntos calientes de piratería a lo largo de las pasadas 2 décadas.
Otras habilidades que aprenderá¶
Usar el representador Mapa de Calor (Heatmap) para una visualización rápida de datos densos en puntos
Crear y usar proyecciones personalizadas de mapa
Obtener los datos¶
El portal de Información de Seguridad Marítima de la National Geospatial-Intelligence Agency provee un archivo shape de todos los incidentes de priatería marítima en la forma de Mensajes de Actividad Anti-barcos. Descargue la versión archivo Arc Shape de la base de datos.
Natural Earth tiene varioas capas vectoriales. Descargue 10m Physical Vectors - Land que contiene poligonos de Tierra.
Para su comodidad, puede descargar directamente una copia de las capas mencionadas previamente de aquí abajo:
Fuente de Datos: [NGA_MSI] [NATURALEARTH]
Procedimiento¶
En el panel QGIS Explorador, ubique el directorio donde guardó sus datos descargados. Expanda
ne_10m_land.zip
y seleccione la capane_10m_land.shp
. Arrastre la capa a la pantalla. A continuación, localice el archivoASAM_shp.zip
. Expándala y seleccione la capaasam_data_download/ASAM_events.shp
y arrástrela a la pantalla.
Una vez que esté cargada la capa, puede ver los puntos individuales que representan ubicaciones de incidentes de piratería. Hay miles de incidentes y es difícil determinar donde hay más piratería. En vez de puntos individuales, una mejor manera de visualizar estos datos es a través de mapa de calor. Seleccione las capas
ASAM_events
y clic en el botón Abrir el Panel de Estilo de la capa en el panel Capas. Clic en el menú desplegableSímbolo único
.
En el menú desplegable de selección del representador, seleccione el representador
Heatmap
. A continuación, seleccione la rampa de colorViridis
del selector Rampa de color.
Ajuste el valor Radio a
5.0
. Abajo, expanda la sección Representación de Capa y ajuste la Opacidad a75.0%
. Esto da un agradable efecto visual de los puntos calientes con la capa de tierra abajo.
Now let’s animate this data to show the yearly map of piracy incidents. Right click on
ASAM_event
layer, and chooseProperties
.
In the Layer properties dialog box, select the Temporal tab and enable it by clicking the checkbox..
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. SelectSingle Field with Data/Time
in Configuration Drop down menu,dateofocc
as Field.
Now a clock symbol will appear next to the layer name. Click on the
Temporal Control Panel
(Clock icon) from Map Navigation Toolbar.
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.
Now you are ready to preview the animation. Set the Step as
1 Year
then click the Play button to start the animation.
Nota
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.
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
.
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')![]()
Select font size as
25
, set background bar colour asWhite
and set the transparency to50%
. In Placement chooseBottom Right
. Now click Ok.
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.
Click on the
...
Output directory to choose the directory at which the images will be saved.
Under the Extent select the layer. Click Save.
Once the export finishes, you will see PNG images for each year (total 18 images) in the output directory.
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.