#TwitterMetrics: Happiness Heat Map :)

The Twitter Happiness Heat Map attempts to find the happiest place on earth by searching Twitter for the ‘smiley face emoticon’ – :) – and creating a heatmap of where the returned tweets originated.


The Data

Getting the data out of Twitter uses the Twitter API, accessed using the python-twitter library. It’s cobbled together using some MySQL databases, formatted into JSON files and displayed using the d3.js graphical library.

The python script runs on a Raspberry Pi and searches Twitter for the :) emoticon every 5 minutes, returning the first 200 results each time.

In order to plot the geographic position the twitter user must have  geographic location activated for their account – only ~2% of users seem to have this so a lot of the tweets are just discarded. In addition, a user’s location is set to where their account is registered rather than the location they tweeted from – this means that if I had my (London) location registered and tweeted “#OMG these Kangaroos are awesome! :) #Kangaroo #AussieRules” while on holiday in Australia then the increase in happiness would be measured in the UK, not ‘down under’.

The other thing to consider is that when you search for :) on Twitter it also returns tweets that contain characters such as :D and :-). They all seem pretty happy though so the script doesn’t filter them out.

I started the script at the start of February 2014 – so far it’s collected 25,074 tweets :)

The Projection

The Twitter data returns the location of each tweet as latitude and longitude which need to be plotted onto a plain using a map projection.

There are a dizzing array of different projections available, from the Winkel Tripel projection to the more esoteric Hammer retroazimuthal projection. The graphic uses the classic Mercator projection as it’s the one most viewers will be familiar with (important where the image of the map has no outlines and instead emerges with the data).

It’s critics say the Mercator projection distorts the landmass around the poles – unless there are a disproportionate number of Twitter users in Nuuk though, it shouldn’t distort the graphic too much.

Leave a Reply