Skip to content
Tech News
← Back to articles

Hengefinder: Finding When the Sun Aligns with Your Street

read original get Sun Alignment Solar Tool → more articles
Why This Matters

Hengefinder exemplifies how innovative tools can make astronomical phenomena accessible and engaging for the public, fostering a deeper appreciation for the intersection of urban planning and celestial events. Its development highlights the importance of combining technical problem-solving with real-world applications, inspiring both developers and enthusiasts to explore the cosmos from their own cities.

Key Takeaways

Next week in Manhattan, the sunset will align perfectly with the east-west streets of the city grid. It’s beautiful, and people know it. Twice a year, crowds gather to see the brief moment when the sun sits perfectly on the horizon, framed by skyscrapers on either side. It’s called Manhattanhenge, after Stonehenge.

I wanted to know how astronomers figure out when Manhattanhenge happens. And if I could figure that out, why limit it to Manhattan?

A shot of crowds taking photos of Manhattanhenge at 42nd St in NYC.

This was one of my first projects at the Recurse Center: Hengefinder, a tool that lets you find a henge pretty much anywhere the sun sets.

The basic steps (and some terminology I would soon learn):

find the angle of a road (its bearing, relative to true north) find the angle of the sun at sunset each day (its azimuth) find the dates when those angles match.

It was appealing to me that this was mostly made up of many sub problems I could either think through thoroughly, or choose to mostly skip (by handing off to a library, a brute-force solution, an approximation, etc.). It’s like a bunch of closed boxes. I left plenty of those boxes closed — I didn’t build my own astronomical model, for instance. Other boxes I opened. And then I found many things I thought would be straightforward that turned out to be somewhat less trivial in practice as my assumptions broke; Like, in reality, you can’t treat roads like flat lines, latitude and longitude don’t behave like a Cartesian grid, and the word “sunset” is more ambiguous than I initially thought. I’ve enjoyed closing the gap between my assumptions and reality.

So, rather than just talking about the project as a whole, I’m going to walk through a couple challenges I ran into in building this, and how I went about solving them. One challenge for each of those supposedly “simple” steps above.

Challenge #1: Finding the road bearing (and rediscovering the Earth is not flat)

The first challenge was calculating the bearing of a street (its angle relative to true north). If you take the latitude and longitude of one address, and the latitude and longitude of another address down the street, you end up with the coordinates of two points on Earth. We can then use some trig to get the angle. My initial (incorrect) guess for getting the road bearing was to take the difference in latitude and the difference in longitude, then just get the angle with atan2 (the inverse tangent).

... continue reading