An example of using Torque, CartoDB’s time lapse tool

For a recent project we were provided with a GIS shapefile of developments (primarily houses) in a suburban neighborhood in Ithaca, NY. We created static maps to show change through time with color coded dots for different time windows but we thought that the dataset was a perfect opportunity to show off CartoDB’s time series tool called Torque. For details on Torque you can visit CartoDB’s website or the Torque GitHub page.

Creating a Torque visualization

Creating a time-lapse visualization with Torque is surprisingly easy, particularly if you’re willing to accept the defaults and don’t need to customize the infowindow and slider. If your data is small, you can test it out using CartoDB’s free account and signing up is quick. Here are the steps for creating a visualization:

1. Upload your data: CartoDB has done a nice job with this, you can select a local file, drag and drop or even use Dropbox. Your data should have a numeric field representing time. In our case this was year.

2. Create a visualization by clicking on your layer and then clicking on the ‘Visualization’ button in the top right corner.

3. Give the visualization a name and save

4. Click on ‘Map View’ on your new visualization and in the table of contents on the right, under ‘Wizards’ choose ‘Torque’ and choose your time field where it says ‘column’

If you’re happy with your visualization it can be shared at this stage. Simply click on the ‘Share’ button in the top right of the visualization and copy the URL and paste in to an e-mail to collaborators.

Customize the display using the CartoDB API

If you want to make further tweaks to your visualization, there is a very good post for the different settings by Azavea here. We also borrowed heavily (stole?) in this example from Javi Santana’s code on GitHub.

One setting in particular that we think CartoDB should add is the ability to change the slider units. As it stands, the default slider does not display actual data (in our case, year) but time steps (1,2,3…). In order to do this we are not able to simply use the URL or iFrame options for sharing the visualization, we had to make the changes using the CartoDB API and adding custom code which, again, was stolen from CartoDB’s Javi Santana.

In the custom code we start by adding a div to store the year information:

<div id="torque-time"></div>

Then we create the initialization function to add the layers and create the map:

Next post

2 responses

Zev,
the customization that you did in the second part (“Customize the display using the CartoDB API”), is it something that can be done using CartoDB interface (CartoCSS Editor)? Or do you need to host the map to make the amendments?

Good question. I depends which piece of customization you’re talking about but mostly you would need to use the API by hosting it yourself. It has been more than a year since I wrote this post, though, and perhaps there are now additional tweaks available through the CartoDB interface.