facebook and mapping



Facebook intern Paul Butler has made a courageous attempt in revealing the electronic social connections worldwide. Turns out we do not need geographers to help us decide where to draw country borders, some clever social scientists with Facebook data should do.

Instead of taking the whole (secret?) Facebook social graph consisting of about 500 million people, the data is based on a sample of “about ten million pairs” of friends, which is combined with their home location. From this information, Paul was able to calculate the relative strength between pairs of cities, which was then normalized by their relative distance. By drawing lines between these pairs on top of each other, and fine-tuning their brightness, a map of visually distinguishable countries and continents naturally appeared. In fact, the map might not be that different from a view on the Earth at night, one commenter at Mashable remarked.

I began by taking a sample of about ten million pairs of friends from Apache Hive, our data warehouse. I combined that data with each user’s current city and summed the number of friends between each pair of cities. Then I merged the data with the longitude and latitude of each city.


At that point, I began exploring it in R, an open-source statistics environment. As a sanity check, I plotted points at some of the latitude and longitude coordinates. To my relief, what I saw was roughly an outline of the world. Next I erased the dots and plotted lines between the points. After a few minutes of rendering, a big white blob appeared in the center of the map. Some of the outer edges of the blob vaguely resembled the continents, but it was clear that I had too much data to get interesting results just by drawing lines. I thought that making the lines semi-transparent would do the trick, but I quickly realized that my graphing environment couldn’t handle enough shades of color for it to work the way I wanted.


Instead I found a way to simulate the effect I wanted. I defined weights for each pair of cities as a function of the Euclidean distance between them and the number of friends between them. Then I plotted lines between the pairs by weight, so that pairs of cities with the most friendships between them were drawn on top of the others. I used a color ramp from black to blue to white, with each line’s color depending on its weight. I also transformed some of the lines to wrap around the image, rather than spanning more than halfway around the world.”








“One of the most interesting / unexpected finds was seeing how closely tied Brazil is to Japan,” Facebook’s project lead Mandy Zibart says. “Brazilians are the third largest immigrant group to Japan… There’s a lot of buried treasure inside here.” When you click one of the multi-colored circles representing countries, related countries burst to life and enlarge based on how many friendships the two countries share. In many cases the results seem strange, so Facebook worked in coordination with an international relations researcher to develop “Closer Looks” for many of these relationships — hypotheses about why Nepal might have a very high number of friendships with Australia, for instance. In that case, Facebook says, the number of friendships could be due to the tens of thousands of student visas Australia has issued to Nepalese students within the last few years.


Facebook offers a source linked below each hypothesis that substantiates the company’s claim. The default view for examining friendships is “by continent,” but you can also click “by language” to view the world color-coded by the primary language each country speaks. It’s easy to explore French colonization in this view, since you can see at a glance which countries speak primarily French.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s