I regenerated by tweet density graphs using contour lines, and got this nice looking animation of tweet density in london over the course of a day.

24 hours of tweets in London

The important improvements:

Use a sliding time window

Before I was using hourly updates, which meant that the updates were quite abrupt, and I could have a maximum of 24 frames per movie. I used this subquery to pull out the number of seconds since midnight, so that I could use a sliding time window of one hour in R:

extract(epoch from created_at::time)

Use contour lines

The contour function in R generates really nice contours from heightmaps. They look nice, and are easily georeferenced.

Resample the density matrix

I sample the tweets in a 50x50 matrix. This works, but gives quite sharp contour lines. The image.smooth function (from the image library) came in handy here, as it uses a gaussian smoothing kernel on each element in the matrix. The default settings gives a nice smooth heightfield which can be plotted by contour

Next steps

After this - I worked out that I could call contourLines to get the line coordinates. Then by converting this to json using rjson, I plotted the contourlines onto a google map using polygons. Finally, I made it so that you can click on the polygons, and see what tweets and neighbourhoods are causing weird spikes of activity.

I’m busy with client work at the moment, so hopefully sometime next week I can push an update to twitterplaces that features these contour maps.