Animar Datos de Series de Tiempo (QGIS3)

El tiempo es un componente importante de varios conjuntos de datos espaciales. Junto con la información de ubicación, el tiempo provee otra dimensión para el análisis y visualización de los datos. Si está trabajando con conjuntos de datos que contienen marcas de tiempo o tienen observaciones registradas en múltiples intervalos de tiempo, puede fácilmente visualizarlos usando el complemento TimeManager en QGIS. TimeManager le permite ver y exportar ‘porciones’ de datos entre ciertos intervalos de tiempo que pueden ser combinados en animaciones.

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:

ASAM_shp.zip

ne_10m_land.zip

Fuente de Datos: [NGA_MSI] [NATURALEARTH]

Configuración

Vaya a Complementos ‣ Adminstrar e Instalar Complementos.... Busque e instale el complemento TimeManager.

../../_images/setup1.png

Procedimiento

  1. En el panel QGIS Explorador, ubique el directorio donde guardó sus datos descargados. Expanda ne_10m_land.zip y seleccione la capa ne_10m_land.shp. Arrastre la capa a la pantalla. A continuación, localice el archivo ASAM_shp.zip. Expándala y seleccione la capa asam_data_download/ASAM_events.shp y arrástrela a la pantalla.

../../_images/19.png
  1. 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ú desplegable Símbolo único.

../../_images/21.png
  1. En el menú desplegable de selección del representador, seleccione el representador Heatmap. A continuación, seleccione la rampa de color Viridis del selector Rampa de color.

../../_images/31.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/41.png
  1. Now let’s animate this data to show the yearly map of piracy incidents. Go to Plugins ‣ TimeManager ‣ Toggle visibility.
../../_images/51.png
  1. In the TimeManager panel, click Settings.
../../_images/61.png
  1. In the Time manager settings window, click Add layer button.
../../_images/71.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 by the plugin to determine the points that are rendered for each time period. Select ASAM_events as the Layer and dateofocc as the Start time. The End time should be set to Same as start. Click OK.
../../_images/81.png
  1. Back in the Time manager settings window, click OK.
../../_images/91.png
  1. Click the Power icon in the TimeManager panel to enable the plugin. Set the Time frame size to be 1 years. Once enabled, you will see a filter icon next to the ASAM_events layer. TimeManager works by applying a filter to the layer based on the selected field and specified time period.
../../_images/101.png

Nota

As TimeManager works by applying a filter on the layer, it only works with layer types that support this feature. Most data source types do support it - with a notable exception being temporary memory layers. If you had done some processing earlier and have a temporary layer, right-click and select Make Permanent before using TimeManager on that layer.

  1. Now you are ready to see the animation. Click the Play button to see the yearly piracy hotspot animation.
../../_images/11.gif
  1. You will notice that for each frame of the animation, a date is displayed at the bottom-right. Instead of the full date and time, let’s change it to display the year that the map represents. Click Settings in the Time Manager panel. Click Time display options in the Time manager settings dialog.
../../_images/121.png
  1. Adjust the Font Size to 25. Change the DateTime format to %Y. The time format should be specified in the Python strftime format. %Y is the short-code for a 4 digit year. Also you can change the Placement direction to NW. Click OK.
../../_images/131.png
  1. Back in Time manager settings dialog, check the Looping animation checkbox. This helps when you are making changes to styling and adjusting styling to make the animation continue playing back from start. Click OK.
../../_images/141.png
  1. Now if you replay the animation, you will see the label will show the year of the animation in the top-left corner. At this point, we can export the animation, but there is one more change that we can apply to make our map better. The default map projection is EPSG:4326 which is ok for storing the source data, but not ideal for global visualization like this. I really like the Equal Earth Projection for a visually pleasing and more accurate representation of the world. It is a fairly new projection and not yet available as a predefined option in QGIS. But there is an easy way to use it in QGIS by defining a custom projection. Go to Settings ‣ Custom Projections....
../../_images/151.png
  1. In the Custom Coordinate Reference System Definition dialog, click the + button. Enter Equal Earth as the name. Enter the following definition in the Parameters box. The parameters need to be specified in the PROJ format. After entering the parameters, click OK.
+proj=eqearth +datum=WGS84 +wktext
../../_images/161.png
  1. In the main QGIS window, click the Current CRS display on the bottom-right corner.
../../_images/171.png
  1. Search for Equal Earth to find and select the newly defined projection. Click OK.
../../_images/181.png
  1. You will see the map transform to the Equal Earth projection. Now we are ready to export the animation. Before exporting, make sure to set the time-slider in the Time Manager panel to the start position. Export of the animation will start from the current position of the time slider. Click Export Video button in the Time Manager panel.
../../_images/191.png
  1. In the Export Video dialog, click Select output folder and select a directory on your computer. Select the Frames only option and click OK to start the export process.
../../_images/20.png
  1. Once the export finishes, you will see PNG images for each year 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.com for an easy and online tool. Visit the site and click Choose Files and select all the .png files. Note that the export folder will also have a .pgw file for each frame which contains the georeference information. You may want to sort the images by Type to allow easy bulk selection of only .png files. Once selected, click the Upload and make a GIF! button.
../../_images/211.png
  1. Once the process finishes, click the Save button to download the GIF to your computer.
../../_images/animation.gif
If you liked tutorials on this site and do check out spatialthoughts.com for more free resources.
comments powered by Disqus

This work is licensed under a Creative Commons Attribution 4.0 International License