life in madrid seen through bicimad

This below is just an image so this looks pretty. The animation I want to
publish is available here if you don’t mind going to
YouTube, or
here
hosted on this server.

BiciMAD has published data about individual trips
made with their
bikes, so
this weekend I downloaded them and I have been trying to give them some shape.
When I started working with this, data from September 2018 wasn’t yet available,
so I chose two days from September 2017 (20, Wednesday –left panel–, and 24,
Sunday –right panel–) to see what it looked like on a working day and a
holiday.

I won’t go into much detail because the
code tells the story. Most of the work
involved reading the data points in a way that made easy to send them to
ggplot2. Map data is by
OpenStreetMap through theStamen API, via
ggmap. If someone wants to run run the code,
it needs the latest development version of this library, installed usingdevtools. The code
writes individual images that I then joined using ffmpeg;
at some point in the past I tried to use some R library for animations but I
didn’t manage to make it work and this has never failed me.

Caveats:

As datapoints ara anonymized (they are all grouped by the hour at which the
trip starts, but no minute or seconds), I’ve simplified the problem and I’ve
supposed that trips are uniformly distributed within each hour. Which they are
not, but it’s good enough for this.
There are some weird trips (several kilometers covered in a few seconds) or
trips that take several days. I haven’t cleaned the data up, I just truncated
the animation at the end of the day.
Probably starting the animation at midnight is not the best option, but I’ve
run this in a quite old computer that was already struggling with one day of
data held in memory. I could have read it chunkwise and then proceed in
smaller pieces, but I’m too lazy already.