Tuesday, February 8, 2011

How to draw a map of Spain when all you have is friendship connections

Intrigued by Paul Butler's visualization of Facebook's friendship links I decided
to try a similar illustration with data from Tuenti, a large Spanish social networking site we (Yana Volkovich, David Laniado and me) are currently analysing here in the Information Technology and Society Group at Barcelona Media.

The dataset contains friendship connections of Spanish users and their city of residence. After some preprocessing of the data done by David in Phyton we obtained a network of cities with weights encoding the number of friendships between cities.

Then all that was left to do was to obtain the geo-coordinates of these cities (which we found here), choose a colormap and draw a line between every pair of cities with more than 50 inter-city connections (the choice of 50 is arbitrary but a good compromise between computation time and visual effects).

If one draws the edges by decreasing distance as described by Paul Butler in this blog entry (thanks to Carlos Ullod for the link) and encode the euclidean distance between the nodes in the colour of the edges, Matlab does the rest. No magic needed.


And this is what we got:


or with a different colormap


and including the Canary Islands


Beautiful, isn't it ?

Notice that we only draw friendship connections, no other geographic information is needed. Spain's geographical shape and population distribution emerge naturally, showing the denser populated regions, nearly unpopulated areas and also the local hubs: smaller cities with many connections to the neighbouring towns.
 
You can find hi-res figures to download here:


P.s.: We would like to thank Dave Currie, Erik Jutemar and Guillermo PĂ©rez from Tuenti for preparing the dataset for us. They did the actual tricky stuff of anonymizing the data and bringing it into a format that we could use.