Building a Moon You Can Fly Around

The moon on moon.tomkrush.com

Earlier this year I started generating software based on research papers and datasets. I did it for a few months and stopped. I think it’s an interesting way to build software, but I was uncomfortable with some of the projects I was attempting to build. I felt reckless not understanding the architecture and domain, so I moved on from most of them.

One of the projects I started in the spring using this practice is planetarium software. I enjoy astronomy and thought this was a good way to dig into the math and science more. I’m taking my time on this project to learn and have fun.

While working on the planetarium software in the spring, I ran into a problem. I put a constraint on myself to only use openly available scientific data, and I couldn’t trace the license of the moon texture I was using. Instead of finding another moon texture, I opted to do the more interesting thing. I wanted to render the moon using only data. It turns out there is a lot of data available A few hours of generating code and researching a few topics, I got the moon working and it was beautiful.

I’m still working on the planetarium software, but I wanted to share what I did with the moon. Last week, I pulled the moon out into a small proof of concept that anyone can open in a browser. I also used as a chance to use a richer dataset.

To be clear: I’ve been building software for 25 years, but I will not claim that I understand this implementation beyond the things that were interesting to me. I do understand many of the high-level patterns and can comfortably dig into most of the codebase, and I enjoy reading documentation and the referenced papers to understand the inner workings.

I built this with Claude Code, using Anthropic’s Claude Opus 5.5 on medium effort. The validation work, the comparisons and the GIFs in this post came out of the same sessions.

What I built

The moon on moon.tomkrush.com is drawn entirely from spacecraft measurements. NASA’s Lunar Reconnaissance Orbiter has been circling the moon since 2009, and one of its instruments is a laser that measures the height of the surface. The same laser also measures how much light bounces back, which tells you how bright the ground is. I combined that with a catalog of about 1.3 million craters and a model of how sunlight scatters off lunar dust. Then I put the Sun, Earth and Moon where they really are, and the renderer works out what you should see.

When you open the page, it shows the moon as it looks right now. You can speed up time and watch the shadows move across the craters, or leave Earth and fly down close to the surface. Watching time pass while looking at the mountains near the shadows is stunning on a large screen.

Sunset over Copernicus crater on November 3, 2026 Sunset over Copernicus crater, about 19 hours of shadow filling the floor. Open in the viewer.

Why a separate project

In the planetarium, the moon is one small thing in a sky full of stars and planets, so I took a lot of shortcuts. It’s basically a flat disc that’s shaded to look round, and it only draws the largest craters. That works when the moon is small on the screen.

This proof of concept exists to share the moon. We all see it at night, and there is so much data on it.

Getting it on the web

I wanted this to be public, which also means it needs decent device support. The most detailed elevation data for the moon is about 66 GB, and that’s before the brightness data and the crater catalog. The early versions had the browser downloading hundreds of megabytes, and my MacBook stayed hot. After several iterations, I got the moon split into 288 pieces, with tiles for the closer zoom levels, so you only download a few megabytes at a time and it stays responsive at any zoom. I’ve watched the network tab enough to know that is remains mostly true, but if you pan a lot, the data does still add up.

I had the agent preprocess everything ahead of time into small packages. The page only downloads the pieces you can see, plus a few nearby ones that cast shadows into view. The far side never downloads if you’re looking from Earth.

I also pushed the agent towards storing differences. Each piece has a low-detail version, and the extra detail is stored as only the difference from it, so you only download the detail your screen can show. Zooming in works the same way: each closer level is stored as the difference from the level above it. The 66 GB of close-up data became 13 GB of small tiles, and you only download the few you’re looking at.

If you want to try it, go to moon.tomkrush.com. Because the moon is drawn live from raw data rather than pre-made images, it relies on a modern browser graphics feature. Any up-to-date version of Chrome, Edge, Safari, or Firefox on a reasonably recent computer, iPhone, or iPad should run it smoothly.

Validating results

I’ve been using reference images to manually compare craters and lighting, and to my eye it looks correct. The images below are different, but it’s subtle. For automated testing, I had the overall brightness checked against the model scientists use to calibrate satellites against the moon, and the surface checked against real photos from the orbiter’s camera. I’m still working through the results of validation. I know brightness still needs to be tuned further. The AI made some assumptions on values that I need to work out.

Each comparison starts with one photo from the orbiter’s wide-angle camera. The camera doesn’t take a square picture. It takes a long, thin strip as the orbiter flies over, so the photo needs some work before it can be compared:

  1. Download the raw strip from NASA’s Planetary Data System.
  2. Calibrate it with ISIS, the USGS software scientists use for planetary images. This turns the camera’s raw numbers into how much sunlight the ground actually reflects.
  3. Flatten it onto a north-up map, using the orbiter’s recorded position and pointing for every line of the strip.
  4. Render the same area. Each slice of the strip was taken a few seconds apart, so each slice is rendered from where the orbiter was at that moment, with the Sun where it was.
  5. Lay the render onto the same map and line the two up. They land within one pixel, about 100 meters.
  6. Show both in grey on the same brightness scale and crop to the area.

The “Original LRO image” link under each pair goes to the raw strip, before any of this.

Each comparison has a link that opens the viewer. It puts the camera where the orbiter was, sets the time to the moment the photo was taken. I also adjust the field of view.

Copernicus crater photographed by LRO's Wide Angle Camera The same view of Copernicus crater rendered on moon.tomkrush.com with matching sunlight
Copernicus on January 8, 2010: one LRO frame (NASA/GSFC/Arizona State University) and a render from LRO's position at that moment, on one brightness scale. Original LRO image · Open in the viewer.
The Apennine Mountains at the Apollo 15 site photographed by LRO's Wide Angle Camera just after sunrise, with long shadows cast west The same view of the Apennine Mountains rendered on moon.tomkrush.com from LRO's position at the same moment
The Apennine Mountains at the Apollo 15 site just after sunrise on December 24, 2009, compared the same way. Original LRO image · Open in the viewer.
The Alpine Valley and lunar Alps photographed by LRO's Wide Angle Camera, in afternoon light The same view of the Alpine Valley rendered on moon.tomkrush.com with matching sunlight
The Alpine Valley on February 3, 2010, compared the same way. Original LRO image · Open in the viewer.

Sunrise over the Alpine Valley and the lunar Alps on November 17, 2026 Sunrise over the Alpine Valley as the lunar Alps catch first light. Open in the viewer.

Why I’m sharing this one

I think building software using openly available scientific data is enjoyable. I think projects like this are a way to celebrate the people who push science forward. The credits page lists the missions, datasets and papers the moon is built from.

If you want to try it, go to moon.tomkrush.com. It needs a recent version of Chrome, Edge or Safari. I’ve tested on several Macs, iPhones and iPads. I also tested on a ThinkPad from a few years ago.

I haven’t posted the repo to GitHub yet. If you find issues, send them to [email protected]. I would be happy to dig into what is found.