Visualising Internet data in Tableau – Velib in Paris

Data

Visualising Internet data in Tableau – Velib in Paris

by Jean Atienza

Available in French – click here.

I love data and I’m always searching for new ways to make more data easily accessible to the Tableau user. In this example, I’ll demonstrate how to access Internet data via a REST API. It might seem slightly complicated, but it’s actually quite easy to reproduce for your real needs. However, should you have any complex and specific needs, Interworks consultants will be happy to help… we love challenges as much as we love data!

You’ll find a lot of websites providing data which you could use in your analysis (weather, stock exchange, airline traffic…). For this example we will build a visualisation based on Decaux Velib data. Velib is an automated bike rental service. Starting in Paris, it is now available in many other cities. As a Velib service user, you may be in search of an available bike around you OR in search of an available stand to return a rented bike.

This dashboard shows all the Velib stations in Paris; a color coding shows the availability level (of bikes or free stands). Clicking on a station will display a Google street view of the station surrounding.

Here is the finished dashboard :

The steps for this example are:

  • Use a Python program to connect to Internet data provider and get the data via a REST API
  • The same Python program will create a Tableau data extract file containing the data in a usable format using an API provided by Tableau (Tableau Data Extract API)
  • Tableau Desktop will then be used to visualize the data from the data extract file

Important: the Tableau Data Extract API only works on a Windows based PC, not on Mac.

This example uses Python as a programming language but the same result can be achieved using C/C++ or Java.

Things to install before we start:

Step 1: Register at Decaux Open data

It is free – Decaux will give you a personal API key, which you will need to access real time data.

The registration process may be different for another data provider but you will end with an API key in most case.

Connect to this URL and follow the registration instructions: http://developer.jcdecaux.com

Step2 (optional but safer): Test your connection/key

From Google Chrome, launch the Postman application, enter the following URL:

https://api.jcdecaux.com/vls/v1/stations?apiKey=enter_your_API_key_here

and click on “Send”; you should get a result like this, displaying the data in a JSON format :

postman

The available data is displayed in JSON format; note that “lat” and “lng” are part of a group called “position”, this is important when referencing a data in the Python script.

Now we know the API key is valid and we have a good view of the provided data structure

Step 3: Python modules

Python comes with a set of standard modules (equivalent to functions or procedures) and additional modules can be added by installing them to an existing Python installation.

3.1/ Download the Tableau Data Extract API for Python (download link provided in the prerequisite part of this document) and install it within Python 2.7

  • After downloading the zip file, unzip it to the “Lib” directory
  • Open a command line window (cmd.exe)
  • cd LibDataExtract-xxx (created by the unzip)
  • python setup.py install

  3.2/ The program also needs an optional Python module (called requests) to be installed (no need to download it):

  • open a command line window (cmd.exe)
  • cd Scripts
  • pip install requests (this will download and install the module)

  Step 4: The Python script

The Python script (.py file to be extracted from the attached zip file) will:

  • Connect to the Decaux Open Data website
  • Read information for Paris bike rental stations
  • Create a Tableau Extract called velib.tde

  Modify the script to insert your Decaux API key where indicated, on line 40, before using it.

The script contains descriptions of the different tasks.

To launch the script, use the following Windows command line:

Python

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072