We've already seen one of the ways that we can develop maps using Google FusionTables. But that method gives us points on a map that don't change over time. This How To on Data Visualisation shows how to animate a map using CartoDB.
We’ve already seen one of the ways that we can develop maps using Google FusionTables. But that method gives us points on a map that don’t change over time.
However, sometimes we do have data that also have chronological information associated with them. The DFID travel dataset is one example of that. There are lots of ways to visualise that information, but one way would be do display all the places DFID have travelled each day of the year. This can be done using an online mapping software called CartoDB and its ‘Torque’ function.
CartoDB is a really powerful mapping tool that has a free version with a number of limits (on data storage, and that all information is public, for example). Monthly paid subscriptions are not cheap, but are certainly worth exploring if you do a lot of mapping. It will likely come out as cheaper than many of the other mapping (GIS) software that is available, making it a solution to explore further!
Step 1: Setup CartoDB account
If you don’t already have an account, the first step is to sign up.
Step 2: Upload dataset
Once logged in, we’ll then need to navigate to the dataset part of our dashboard.
Once there, we want to ‘connect to’ (well, upload in our case) a new dataset. Click the green button at the top-right corner that says ‘new dataset’. You’ll notice that there are a number of options for how to connect to datasets. To maintain live links (i.e. to data that will be constantly updated in Google Drive Spreadsheets) a paid account is required. Therefore, were’ going to upload an Excel file.
The file we’re working with is available to download as a Google Spreadsheet. Do note that in order for this to work correctly, you may need to make sure that the date field is displaying correctly (i.e. as a date and not as a raw number). Once you download the spreadsheet and are working in Excel, it is possible to change the format type for that column to a date type.
In CartoDB, click the blue ‘select a file’ button, navigate to the file and upload. At the bottom of the screen, then select the green ‘Connect dataset’ button. A status bar should appear as the information is processed. After it a successful upload, you will be automatically redirected to the dataset on CartoDB.
Step 3: Ensure columns are correctly coded
When uploaded, CartoDB guesses what kind of information is in each field. For example, it will identify a name as a ‘string’ (i.e. text), or a number or a date.
In this case, it’s particularly important in this example that our ‘travel_date’ field is considered to be a date. If it’s not, select the identifier under the ‘travel_date’ label and a dropdown menu will appear. Simply select date.
Step 4: Georeference our data
In order to map the data, it needs to be georeferenced. We already have some geographical data in our dataset: both the latitude and longitude of the departure and destination airports.
But CartoDB is a powerful tool that can help to groreference data in a number of different ways.
We want to map the destination city of travel for all DFID staff across 2011. To do this, we want to georeference based on the column ‘dest_city’.
There are a few ways to do this, but the easiest way is to select the ‘Edit’ dropdown menu at the top-right corner and select ‘Georefernce’. A dialogue box will popup with a number of georeferencing options. Instead of georeferencing by latitude and longitude, we’re going to select the second option to georeference ‘by city names’.
Two dropdown menus appear. We’ll select ‘dest_city’ in the city name menu, and ‘dest_country’ in the country menu. The country column isn’t necessary, but it will help CartoDB avoid confusion between two cities with the same name, e.g. London in Ontario, Canada, and London in the UK.
Select continue twice, and your data will be automatically georeferenced.
Step 5: Create a torque map
We now have all the data we need. So switch from data view to map view using the button at the top-middle of the screen.
Open the right-side toolbar by clicking on the number one. We want to change the map type, so make sure that you’re under the ‘wizard’ tab by clicking the button that looks like a paintbrush.
We’ll then select our desired map type: in this case, ‘torque’. You’ll see that the map automatically starts moving.
We then need to make sure all of the settings are as we desire. First, make sure that in the ‘Time column’ dropdown menu, ‘travel_date’ is selected. You may notice that in the bottom-right of the map, it changes from sequential numbers to now show the dates of travel.
We can change the marker type between rectangles and ellipses. In this case, I prefer keeping the markers on the map as small circles. We can further change the colours of those circles (here I’ve changed to navy, DFID’s brand colour).
The other settings are more important. Duration changes how long the overall visualisation will last in seconds. The default is 30 seconds. That seems about right for this visual, but if you want to slow it down, try it at 60 seconds.
Steps is how many different individual maps it creates to get through all of the data. It would be great if we had the option of 365 (for one map a day), but the closes option is 256, so let’s choose that one.
The other interesting one is ‘trails’. This indicates after a point initially appears on a map, how many steps should it take before it fades out and completely disappears. In this case, I’ve bumped it up from two to four, otherwise I find it disappears very quickly.
Finally, I’ve changed the resolution to 1 from 2. This means that if there were two cities nearby, it might have only shown one dot. But I want to see Kampala versus Nairobi, for example, so let’s make it the highest resolution.
The last thing you could do is turn on the cumulative tab so that the dots don’t disappear. I’m keeping it off for this visual.
Step 6: Publish and share the map
At the top-right corner of the page is the option to then publish and share the map. Click the map to go to the live and interactive version.