In epidemiology, analysis of data by space (mapping) and by time (e.g. epidemic curves) are seen as essential tools for understanding disease dynamics and causal factors. However, temporo-spatial visualisation has been less commonly used because of the complexity of the tools available. This blog describes the use of the QGIS Time Manager plugin to easily visualise disease outbreaks, based on World Organisation for Animal Health (OIE) Immediate Notification data.
For this blog we will be using data from the 2014 and 2015 Foot and Mouth Disease outbreaks in North Africa (Tunisia, Algeria and Morocco) to illustrate the technique.
Getting the data
There are two main sources for OIE immediate notification data: through the FAO EMPRES-i system, and from the OIE WAHIS directly.
Downloading disease outbreak data from the EMPRES-i website is quick and easy, but not as intuitive as it could be.
- Open the EMPRES-i website
- On the menu on the left, select Disease Events
- Choose the disease you want (in this case, Foot and Mouth Disease) or ‘All Diseases’
- Using the widget on the left of the map, check the ‘Select Area’ radio button, and set the time period you want (last 2 years is the maximium)
- Using the arrows and zoom bar, pan and zoom the map to the area that you are interested in, then click and drag the mouse to select a box around all the indicated disease outbreaks. Be patient, the site is rather slow to update.
- The list of selected outbreaks will be displayed in a scrolling box at the left of the map. At the bottom of this box is a little PDF symbol and beside it, a little (cryptic) CSV symbol. Click on this symbol to download the selected data.
To save time, I’ve saved a copy of the file so you can download and play with it. The file can be opened in Excel or OpenOffice to examine the data, and consists of the following fields:
- Diagnosis Source
- Locality Name
- Locality Quality
- Observation Date
- Reporting Date
- Species Description
This is great to get started as it contains the latitude and longitude of each outbreak, as well as the start date, the content and arrangement of the data leaves something to be desired. The main problems are:
- The species are aggregated, so for a disease that can affect multiple species, it is not possible to work out the numbers of animals of different species affected.
- There is no end date for the outbreak (which is useful for animation of the outbreaks)
So, while this data is a great source of information, if we want to get the full details, we need to go to a little more effort, and visit the OIE’s World Animal Health Information System (WAHIS).
The OIE WAHIS system has all the details required, but is not nearly as convenient or friendly as the FAO system for downloading data. There are two options:
Record by record lookup
For small data sets, it is possible to search through the site, one outbreak at a time, and manually transcribe the required information.
- Click on the Disease Information menu at the top and select Immediate Notifications and Follow-Ups
- Select the disease and year (if you want more than one year, you’ll have to repeat
- Find the country of interest, and then click on the number in the column for ‘Number of outbreaks’
- For each outbreak in that list, click on ‘View’ in the Details column
- This opens the outbreak details, with coordinates, start and end dates, as well as a breakdown of the number of animals affected and at risk for each species. Transcribe these details into your database (good luck if you are dealing with more than a handful of outbreaks)
Automated trawling of the web site
A simpler approach is to automate this data extraction. If you know Python, and have it installed on your computer, then you can use this python code. It is far from perfect, as I am only an amateur python user, but it does the job. You are likely to need to tweak it slightly with file names and paths, and you may have to install some libraries. Only embark on this adventure if you know what you are doing. An example of the output is available here. To view in Excel, you’ll need to break up the tab and quote delimited columns using the Text to Column feature in Excel.
Now we have the data, we can start to analyse it.
The epidemic curve (outbreaks per day) for Algeria is shown below.
The corresponding curve for Tunisia is:
A static map of the outbreak locations is shown at the top of this blog. While the map and epidemic curves reveal insights into the disease in the different countries, the combined time and space picture would be even more revealing.
Importing into QGIS
The simplest way to get the data into QGIS is to directly import the CSV file. Open QGIS and from the menu choose ‘Layer’, then ‘Add layer…’, then ‘Add delimited text layer’ (or click on the corresponding tool in the toolbar). Complete the dialog as shown in the image below:
Select WGS 84 as the CRS and click OK.
The aim is to run a ‘movie’ of the outbreaks, showing where, when and what species were involved.
Set the layer style
First, set up the style of the layer to animate. For this exercise, we want to display a pie chart, with different colours for the different species affected, and the size of the pie proportional to the number of animals affected.
First, open the layer properties, and Diagrams from the left menu. Select the value for the number affected for each of the species, and set the colours as shown below.
Then set the size proportional to the number of affected animals. Click on the Size option in the Diagram editor. Use the formula compose to set the Attribute value to be the sum of the number affected for all the different species, as shown below.
Finally, adjust the placement to the centre of the pie chart, and any other settings you want.
You should end up with something like this:
Set up the animation
First, install the TimeManager plug in: Click on the Plugins, then Manage and install plugins…, then search for and install TimeManager.
Once installed, you can display the TimeManager control panel by clicking on the Plugins menu, TimeManager, Toggle visibility.
In the TimeManager control panel, click on the settings button, then Add layer. Choose the layer (fmd_2014-16), start as Start Time, end as End Time and leave the other fields as they are.
Press OK to close the layer dialog, then OK again to close the settings dialog.
In the control panel, set the time frame size to 1 day, and click the green On/Off button to activate the TimeManager display.
Finally, click the Play button (forward arrow) below the time scale bar, sit back, and enjoy the movie. For the impatient, you can also drag the time scale slider back and forward to examine more closely what is going on.
Here is an example of the final result: