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.

14 comments:

  1. Hi, great Work!! May I ask what visualization software do you use for drawing the map geo-referenced?

    ReplyDelete
  2. @Marcel
    Once you have the data in the correct format, its just a few lines of code in Matlab, nothing else.

    ReplyDelete
  3. Hi Andreas Thanks for the answer! I am thinking about the map? Did you use the map from google maps? And how did you handle the geo-reference (lat,long) in the map ? I am thinking to create also one for showing the friendship connections between a social network that I manage here at Brazil: http://atepassar.com
    Thanks Andreas,
    Marcel

    ReplyDelete
  4. Hi Marcel

    You only need the geo-references (lat,long). Use them as what the are, coordinates, and the map will emerge by itself. The connections will draw it.
    Good luck with your data.

    Andreas

    ReplyDelete
  5. If you are interested Andreas, I've done a simple interactive infographic with the evolution of members of our python local community here using the visualization tool Gource. Originally it is used for visualizing software version control, but I adapted for showing the history of our local community. Take a look:
    http://aimotion.blogspot.com/2011/02/google-group-members-evolution.html

    Thanks for the help :D

    Marcel

    ReplyDelete
  6. Hi Andreas,
    The source code of your project is available on Github or anywhere else ? I had some difficulties in the projection of the lines in my example. I believe I've done in a different order (long lines or small lines first).
    Cheers,
    Marcel

    ReplyDelete
  7. Hi Marcel

    I sent you the corresponding code fragments via mail. Please let me know if anybody else is interested.

    Andreas

    ReplyDelete
    Replies
    1. Hi Andreas - this is a really old post, but I was wondering if you still have that Matlab code sitting around? And if so, if you would mind sharing it with me (see email address below)? I am working on biological networks and have been drawing them by hand, which is painful!! Your image above is fantastic, and something like it might work for visualizing my data. Any helpful hints/tips on how to code the input file would be really appreciated as well.

      Stellar Work!
      Elizabeth Sbrocco (elizabeth.sbrocco@gmail.com)

      Delete
  8. Hi Andreas,

    I'd love to have a look at your code too. Thanks a lot for this lovely example.

    Al.

    ReplyDelete
  9. @alzindiq

    Ok, If you tell me where I can send you an e-mail with the corresponding information.

    ReplyDelete
    Replies
    1. hey,

      Could you please mail me the code too?

      f.vermorken@gmail.com

      Thank you in advance;

      Alphons

      Delete
  10. Hi Andreas,
    Could you mail me the code too? Came across this via tuenti.com.
    my email id is prathmeshpandey1@gmail.com

    ReplyDelete
  11. Hello, could you send me the code?
    thank you so mucho!!
    my email is: vero_52_2000@yahoo.com.mx

    ReplyDelete
  12. Hello
    Could please send me the code?

    salaldos706@gmail.com

    ReplyDelete