Answering 'what colour is London?' with magick and rtweet

rOpenSci package or resource used

What did you do?

I used rtweet to extract the images and body text (containing coordinates) from tweets by @londonmapbot, a bot that tweets satellite images of random parts of London (disclaimer: I made the bot). Then I used magick to simplify each image to a single colour and extract its hex value. I used this information to create some visualisations of ‘the colour of London’.

Functions used: rtweet::get_timeline(), magick::image_read(), magick::image_crop(), magick::image_quantize(), magick::image_resize() and magick::image_data().

URL or code snippet for your use case

I wrote a blog post, What colour is London?, which contains the code and some visualisations.

Image

The image below shows 625 randomised points over a map of the outline of Greater London. Each point is a location sampled by the londonmapbot twitter bot, which tweeted a satellite image for those coordinates. I scraped the image and latitude-longitude data with {rwteet} and reduced the image to a representative colour with {magick}. The colours are largely different shades of browns, greys and greens.

The image below shows a 25 by 25 pixel grid, where each square is one of the locations sampled by londonmapbot that’s been scraped with {rwteet} and reduced to a representative colour with {magick}. The pixels are ordered from top-left to bottom-right by luminosity.

Sector

Personal.

Field(s) of application

Geospatial; image analysis; Twitter bots.

Comments

Thank you Mike, Jeroen and rOpenSci for your efforts on these packages.

Twitter handle

@mattdray
@londonmapbot

3 Likes

The first image is “dark muted grey”. Yes, I cheated and used your package :grin:

dehex::dh_solve("#48503E")
#> [1] "dark muted grey"

Created on 2021-08-23 by the reprex package (v2.0.0)

2 Likes

Oh, and I just remembered I once tried to sort pictures by color myself: Rainbowing a set of pictures · Maëlle's R Blog :slightly_smiling_face:

2 Likes

Haha, I think this constitutes the first use of that function in the wild! :woman_artist:

2 Likes

I like the verb ‘to rainbow’, I think I’ll be using that from now on :rainbow:

2 Likes

thanks for the awesome information.

1 Like