Sunrise, sunset
March 8, 2018
I grew up in Budapest and moved to the Netherlands a few years ago. I could not ignore the fact that the Sun has very different patterns: it rises later and sets later here than in Budapest. However, this difference is not uniform: my feeling was that the sun rises much later and sets about the same time during the winter. I saw the inverse in the summer: Dutch summer evenings are much longer, but dawn does not lag behind that much. I wanted to verify this feeling in a scalable manner, so I created a website (code here) where you can pick two arbitrary locations on the globe and see a graph with their dawn/dusk times through the year.
To be precise, the map shows the times of civil twilight. According to the Wikipedia article on twilight, under clear weather conditions, civil twilight approximates the limit at which solar illumination suffices for the human eye to clearly distinguish terrestrial objects. In other words, this is when you or I would say that it is now dark outside.
There are many intersting comparisons one can make.
- Iceland vs The Democratic Republic of the Congo: extreme within-year differences vs almost constant sunrise/sunset times.
- Bergen (Norway) and Málaga (Spain) are both in Europe and in the same time zone, yet their patterns are quite different.
- There can be half-hour differences between locations even within a country as small as Hungary.
- New South Wales vs Queensland in Australia: NSW has DST, Queensland does not.
I encourage everyone to play around with the map and compare these places – or whatever location comes to their mind.
What did I learn?
In addition to verifying my hypothesis, building this website was a great learning experience. This was the first time I really used JavaScript. I learnt how to combine data from multiple APIs, used various open source packages, and wrote quite a bit of logic myself as well. All in all, I used:
- Bootstrap for the general layout
- timezonedb.com’s API to get time zone information based on geographic coordinates
- Nominatim, an OpenStreetMap API to get the name of the location that was chosen
- SunCalc to calculate dawn/dusk times
- Datejs to work with dates
- C3.js for the graph
- Leaflet for the map
- leaflet-color-markers for the orange marker on the map.
- Google Fonts for the typeface (Crimson Text)
Cover image: Sunset in Amsterdam. Photo by the Author, 2016. Creative Commons CC BY-NC-SA 4.0