Making Sarkoa interplanetary.

Project date Cartography · Planetary mapping

Sarkoa isn’t just for Earth anymore - you can now put maps on the Moon, Mars, Venus, Mercury, Ceres, Europa, Ganymede, Callisto, Io, and Titan.

Taking a web mapping engine off Earth sounds like a gimmick until you actually try it, because Earth assumptions are baked into everything. The one that taught me the most was the simplest: how long is a metre?

Here’s the bug: I asked the renderer to draw a 10 km hexagon on the Moon, and it came out 2.73 km wide — 3.67× too small, because the renderer was still doing math in Earth metres.

Two hexagons against a dashed outline of the 10 km hexagon that was requested. Drawn with Earth metres, the hexagon covers 2.73 km on the Moon. Drawn with the Moon’s radius, it fills the outline.

The arithmetic behind the figure: 10 km ÷ 3.67. Radii and the calculation

One tile grid to rule all eleven worlds

Quick background. Every web map on Earth uses the same trick, called Web Mercator: flatten the globe into one big square, then cut the square into tiles, with each zoom level cutting it four times finer. Every tile has an address (zoom, column, row), and the whole stack - storage, cache, viewer - is built around those addresses.

Every body in the solar system has its own coordinate systems defined by the IAU’s working group on cartographic coordinates. The textbook way to support them is to store each dataset in its native planetary projection and teach the tiler, cache, and viewer about every single one. That touches every layer of the stack and basically invites subtle regressions into Earth maps.

So I took a shortcut that worked out way better: every planetary raster is stored on the standard Web Mercator grid, computed from that body’s own planetocentric longitude and latitude (−180 to 180, east-positive). (Planetocentric just means the angles are measured from the centre of the planet.) In other words: I flatten Mars into the same square and cut it into the same tiles. The square doesn’t care what it’s a picture of.

Treating the grid as a grid of angles - so many degrees across, not so many metres across - paid off right away:

  • Zero changes to the tiler or cache. A zoom-5 Mars tile is addressed identically to a zoom-5 Earth tile.
  • Earth maps stay byte-identical. Earth doesn’t even carry a body field.
  • Downloads still return the untouched original file in its native CRS. The angular grid is strictly internal.

Distances: Earth metres don’t fit on the Moon

The catch with reusing Web Mercator is that all its internal “metres” assume Earth’s radius (6,371 km). A degree is the same slice of the circle on any ball, but the smaller the ball, the shorter that slice is on the ground. Walk one degree around a beach ball and you’ve gone a few millimetres. Walk one degree around the Earth and you’ve gone more than a hundred kilometres. Using the IAU cartographic constants, one degree at the equator is ~111.2 km on Earth, vs. 30.3 km on the Moon.

Every metric number in the viewer fell into one of three buckets:

  1. Displayed to humans (scale bars, measured distances, areas) -> scale by the body’s radius right before display.
  2. Internal MapLibre math (metres in, metres out) -> leave completely alone; converting these breaks things.
  3. Real-world sizes drawn onto the grid (like a 10 km lunar hexbin) -> convert into Earth-grid units before handing to the renderer, otherwise Earth’s 3.67× larger radius (6,371 km ÷ 1,737.4 km) shrinks your lunar hex down to 2.73 km.

The hexagon bug was a bucket-three number being treated like a bucket-two number. Once real-world sizes were converted on their way in, the 10 km hexagon filled its outline.

All posts