The new Spain: redrawing the country using mobility data

AI of Things    22 June, 2017

One of the most exciting fields that the use of data opens up is the study of networks. Our societies, communications, infrastructure, businesses and many other areas of life can be represented as a series of interconnected elements or networks that are constantly fed by data. 

The birth of platforms such as Facebook, Twitter or Instagram have turned social networks into a regular part of the daily lives of all citizens, with the consequent growth of the data generated by these networks being of great interest. The analysis of these network allows us to determine the most relevant people in the network, communities of users, people who are part of multiple groupings….For example, in Figure 1, you can see an analysis of my Twitter activity.

Figure 1 : Example of my network of ‘followers’ and ‘following’ on Twitter using the Gephi too, showing (clockwise from ‘música’) Music, Friends and Celebrities, Work Colleagues & Gaming and Internet.

These techniques are not just reserved for social networks. Any network can be subject to this analysis, meaning that we end up with examples that are as varied as a network of interactions between different proteins and a network that represents the exact connections of the neurons in the brain of an insect. With the data available to us at LUCA we can carry out a similar study using live mobility data. Driven by curiosity, we decided to build a map of the regions (of Spain) based on how we move, whilst leaving out the administrative divisions of the autonomous regions or provinces.

Obtaining the data

At LUCA, thanks to the Smart Steps platform, we have all the mobility data that we need available to us in a simple form. In the case of this study, we used data from January 2016 in Spain at both a provincial and municipal level. From there, we built a network in which the vertices are the provinces or municipalities and the arcs that connect them are given a size proportional to the number of people that have travelled between the two points (figure 2).

Figure 2 : Representative network of movement between Madrid and Toledo (500 people moving from Madrid to Toledo, and 200 in the opposite direction).

This visual representation of the network can be made using freely available tools such as Gephi and igraph. After this, we decided to apply an algorithm to detect the communities. These algorithms detect natural groups of notes (in our case the provinces or municipalities) basing itself on the interconnectivity between them, in such a way that very connected nodes will tend to appear as if they are in the same region. We have used the “Infomap” algorithm. The interesting thing afterwards is the the algorithm decides how many regions ought to be generated. With this information we can them visualize the date, gathering it in a map so that the analysis may be easier and more natural.


Firstly, we carried out the algorithm on a network of mobility between provinces. The provinces are colored based on the one they were assigned, and the province in bold of each region is the one with the highest mobility. The results of this calculation is shown below:

Figure 3 : Regions at a provincial level.

The first thing that can be seen is that the country is represented in 7 compact regions and has a radial structure (perhaps influenced by the structure of major highways), that’s to say, one central region and then regions that surround it. Except in the case of Extremadura, no mobility region lines up exactly with the known administrative limits,  due to unions (Aragón and Cataluña) and separation (Castilla La Mancha).

The next step is to improve the detail of the map at a far more local level to obtain information about the behavior of the municipalities. The data already obtained allows us to have this precision without any difficulty. In the same way as in the previous map, we colored the municipalities according to its region and marked the municipality with the highest mobility as the most important.

Figure 4 : Regions at a municipial level

We can draw various conclusions from this map. The first is that many regions are formed around large municipalities, which are on the whole provincial capitals. One can understand the region as the area of influence that these main municipalities have. We can also see that the regions are strongly influenced by the network of highways. The most important municipality in every region is found at the intersection of the main roads (highways and freeways) and this quality helps them to develop and have a growing importance in the area.

Is is also interesting to observe that the regions respect (in the majority) the regional limits, which indicates that, despite being able to go to the nearest city, the population usually moves about within their own region. Nevertheless, it is common that a region will be fragmented internally into various communities, mainly due to the existence of various important nuclei of the population.


The knowledge extracted from this analysis can serve many uses:

  • Transport and infrastructure: since the map is obtained using information about mobility, it is evident that this would be the first use. By understanding the distribution of these regions we could re-plan the road network. For example, it would be interesting to have good connections between all the municipalities that are capitals of their region, or between the towns of the region and their “capital”. It would also be interesting to study the boundaries of the regions: by showing us that two regions are separated the algorithm indicates that there is low traffic between them which could suggest that there is poor infrastructure that forces the population to use other routes. We can also use the analysis to study the impact on mobility before and after a new highway is built.
  • Institutional buildings: these maps highlight the regional capitals that could be perfect locations for housing institutional buildings, such as local Police and Internal Revenue offices. This would result in a better service for the citizens, a reduced need for traffic and an offloading of the saturation of these services in the capitals of the provinces o autonomous regions.
  • Healthcare and Emergency Services: within the institutional buildings, we would like to highlight the case of medical services. Due to the need for fast responses, a geographic distribution is more than necessary. Using the above information can help to locate these services not just in the areas around which the populations are based, but in those areas that bring various mobility benefits. This is because the users will not only be closer to their hospital but they will also know the area better, as it will be in the municipality that they are most accustomed to visiting. 
  • Tourism: one can adopt a strategy of advertising the municipalities in the zone of influence of the region, knowing in hindsight that tourists will probably travel to spend a night in the capital of the region. This will improve the general incomes of the region since tourist will have more sites to visit and will spend more time in the area.
  • Trade: the zone of influence of a municipality tells us which ones will potentially be the beneficiaries of a new business, allowing for a more precise study of its clientele. 

In summary, the analysis of mobility data using networks offers us a new vision of our concept of regions and provinces, and gives a complementary vision of the dynamics of our society. Apart from satisfying out curiosity, it helps us to understand the behavior of the population, the regional groupings that form from movement, and to know the province and reference municipality…This allows us to act in a more intelligent way, maximizing the benefit for the population.

What do you see in the maps?

Leave a Reply

Your email address will not be published.