Real time status of municipal bike stations
Presenting an example of how to access JCDecaux Open Data API for several municipal bike services from MATLAB. The city of Valencia (Valenbisi service) is used as an example. Code is available in GitHub under the GNU license.
Summary
JCDecaux offers real time status updates of their public bike services around the world, a very valuable information if one wishes to gain insight of city dynamics, transportation necessities, etc. This MATLAB script can help to understand how to use this information.
Requirements
Assuming that you have read the API docs and got a key with real-time data reading permissions, you need to save it in a matfile like this:
1
2
apiKey = 'YOUR_KEY_HERE';
save('apiKey.mat','apiKey');
The proposed script (available here) can work as standalone, but I’ve used two libraries from the MathWorks Matlab Central which you can either download (their URLs are included in the source) or disable.
Tip: Browse Oliver O’Brien’s Bike Share Map for an example of a neat web application built upon this data!
Example result: Valencia
This example script gets the status of the municipal bike service of the city of Valencia and plots a simple visualization of it, conveying the number of bikes available on each station, their ocupation rate, and some simple statistics. Also, a Voronoi diagram is plotted on top of it, showing the “cells” that each stations should, in theory, cover.
Another interesting result comes from the comparison of the network status between noon and midnight. In the following figure you can see such a comparison, which hints at a clear differenciation of ‘‘working’’ zones (mainly the city centre and the university campuses at the top right) and the ‘‘living’’ zones (the belt around the city centre).
The color of the stations is almost the opposite between the two snapshots! Also, an animation of this process is available at the bottom of this post, showing the hours at which this change occurs.

Further examples
Global status
As all cities serviced by JCDecaux are also accesible through the API, it’s easy to loop through all of them in order to build a global visualization of the service status. You could use a code like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
url = 'https://api.jcdecaux.com/vls/v1/contracts';
rawData = urlread([url '?apiKey=' apiKey]);
contracts = cell2mat(loadjson(rawData));
for i = 1:length(contracts)
try
% Make the script a function and comment out
% the contract name, passing it as an argument
JCDstatusPlot_function(contracts(i).name)
catch error
disp(error)
end
end
This should allow you to build a global snapshop like this one (try to spot Paris!)

Animation
Another interesting option is to save a snapshot of the status of a contract every few minutes and then loop through the images in order to create an animation displaying the ‘‘flow’’ of people across the city. In this example, you can see people flocking to the city center and the northwest university campuses at around 8h-9h, going to the beach at around 16h, etc.
Licensing
This script is licensed under GPL v3.
