Sunrise sunset

Some 10 or so years ago, I sought some data showing sunrise and sunset times throughout the year for New York and London. I was interested in how the day lengths and sun times differed between the two cities, having lived in both. Below is the result.

It was hardly rocket science. But it showed how New York’s winter days were longer than London’s, while London enjoyed longer summer days. The spikes represented the slightly different times at which our respective clocks changed to summer time.

Roll on ten years, and on a whim I decided to recreate this in Tableau. Before doing so, I didn’t revisit the original work. (“Work” here is a word used in its loosest form.) I vaguely remembered what it had looked like, but in hindsight I didn’t fully appreciate how truly ugly it had been.

So the other evening I set about cobbling together the sunrise and sunset times again. This time, picturing how my Tableau viz might look, I augmented it with some other cities:

  • Glasgow: to see how northerliness within the UK affects things
  • Reykjavík: to see what happens when you go even further north
  • Sydney: to add a representative from the Southern Hemisphere
  • Singapore: as it’s almost exactly on the Equator
  • Rio de Janeiro: because Sydney was looking lonely in the Southern Hemisphere

The first chart was straightforward to create.

A dual axis plot of the sunrise and sunset times by day, coloured by city; and day length below it. Things were complicated slightly by the fact that in summer, Reykjavík’s sun sets after midnight. Only by three minutes or so, but that necessitated a little Excel pre-prep jiggery-pokery.

This is when I got a little excited. The curves were beautiful. I was mesmerised by the fact that the equinoxes saw 12-hour days for the whole world, with the lines all meeting beautifully. I should have known this, but it was nonetheless beautiful to see, something that wasn’t apparent in the ugly Excel viz.

Here, I added a couple of little tricks. I allowed the user to remove the daylight saving element, thus smoothing the lines. I did this by using a time field that I had to convert back to the non-summer equivalent. And I also gave the option of artificially flipping the cities in the Southern Hemisphere to the Northern Hemisphere. This I did by artificially shifting the dates in the first half of the calendar to the second half and vice versa. So viewers could now compare Sydney to London in a meaningful way.

I then decided to throw in an additional viz that showed the height of the sun at its peak, using a full circuit from 1 January at the top, moving clockwise through the year to 1 July at the base and then back to the top. This involved intricate trigonometry and many iterations of buggy code. But it was utterly satisfying when it all came together. I found Singapore (green) carved a fascinating pattern.

And finally, more as an intellectual challenge than something overtly tangible, I decided to add the direction of the sunrise and sunset to the tooltips, not as degrees clockwise from north as the data was pulled, but instead as traditional compass bearings. So instead of giving the user 71°, they are presented with the delectable E 19° N.

The full viz can be found here. Hope you like it.

Leave a Reply

Your email address will not be published. Required fields are marked *