What a machine does with it

A screen map is a pyramid of tiles

The scheme every slippy map runs on is a coordinate system with three integers and one projection, and almost all of it is forced. A square world is what makes the quadtree work, the levels are exact powers of two, and the published resolution — 156,543 metres per pixel at zoom zero — is a distance on the ground at exactly one latitude.

Nearly every map anybody looks at now is delivered as square images of 256 pixels, indexed by three integers, drawn in one projection. The scheme is usually described as an implementation detail. It is a coordinate system, it is almost entirely forced by one requirement, and the requirement is not the one usually given.

The tile pyramid, four levels down to quadkey 120. The world as a square, quartered three times. Each level's tile is exactly half the width of its parent, so a tile is four tiles at the next level and never needs resampling to serve one — the property the whole scheme rests on, and one that holds only because the projected world is square. Level 3 has 64 tiles at 19567.9 metres per pixel, which at 51.5° north is 12181.3 metres of ground per pixel rather than the number the scheme publishes.
Fig. 1 The world as a square, quartered three times. Each level’s tile is exactly half the width of its parent, so a tile is four tiles at the next level down and never has to be resampled to serve one. The numbers on the right are what a pixel is worth: the published resolution, and the ground distance it covers at 51.5° north, which is smaller by a factor this essay’s whole second half is about.

What the scheme actually is

Three integers name a tile: a zoom level zz, and a column and row xx and yy within that level. At level zz there are 2z2^z tiles across and 2z2^z down, so 4z4^z in total — one at the top, four at the next, and 274,877,906,944 at level 19, which is a number no one has ever drawn.

Each tile is an image of a fixed pixel size, conventionally 256 across. The whole world at level zz is therefore 256×2z256 \times 2^z pixels wide, and since the world is a fixed number of projected metres wide, the metres per pixel follow immediately:

r(z)=2πR2562zr(z) = \frac{2\pi R}{256 \cdot 2^{z}}

with RR the radius the projection uses. That gives 156,543.034 metres per pixel at level 0, 38.2 at level 12, and 0.299 at level 19. Those are the numbers every scheme publishes, and they are exact rather than rounded: the level is a power of two and the world’s width is a constant.

Why it has to be a square

The property that makes the whole thing work is that a tile at one level is exactly four tiles at the next. Not approximately, not after resampling: the same ground, cut in quarters, at twice the linear resolution. That is what lets a cache hold one level and serve requests at another without touching a pixel, and it is what makes the index a tree rather than a list.

So the requirement is that the world be covered by whole squares at the root, and with a single root tile that means the projected world must be exactly as wide as it is tall. That condition is the origin of the scheme’s most-quoted oddity, the cut at 85.0511287798° of latitude: Mercator’s northing runs to infinity at the pole, so a cut is unavoidable, and the cut that makes the world square is at the latitude whose northing equals half the world’s width — one number, forced by the choice of a one-tile root.

The qualification in that sentence is load-bearing and is the subject of the square costs the poles. A root of m×nm \times n tiles works just as well, and allows any world whose aspect ratio is the rational m/nm/n; the geographic tiling has used a two-tile root and a 2:12{:}1 world all along. What the square is forced by is not the quadtree but the decision to start from one image.

The cut at 85.0511°, and the alternatives that are not square. Mercator's northing runs to infinity at the pole, so a tiling has to stop somewhere, and the latitude is not a rounding: 85.0511° is where the northing equals half the world's width, which is the only cut that makes the projected world a square. The bars are what other cuts would give — at 89° the world is 1.51 times as tall as it is wide, and a single square root tile cannot cover it. The price is 0.373 per cent of the Earth's surface, 1,901,487 square kilometres in two caps, computed from 2πR²(1 − sin φ) rather than estimated.
Fig. 2 Where the cut has to be, and what the alternatives would give. At 89° the projected world is 1.51 times as tall as it is wide, and a rectangle in that proportion does not quarter into squares. The price of the choice is 0.373 per cent of the Earth’s surface, 1,901,487 square kilometres in two caps, computed from 2πR²(1 − sin φ).

The cut’s own number falls out of that sentence in one line, and it is worth doing because the figure is usually quoted rather than derived. Mercator’s northing is ln tan(45° + φ/2) in units of the sphere’s radius, and half the world’s width in those units is π. Setting the two equal gives tan(45° + φ/2) = e^π = 23.1407, so 45° + φ/2 = 87.5256° and φ = 85.0511287798°. The exponential of π is the whole of it: the latitude is not a compromise between anything, it is the place where one transcendental equals another because somebody wanted one image at the root.

That also says how the number would move under the alternatives. A two-tile root halves the required northing to π/2, giving e^(π/2) = 4.8105 and a cut at 78.69°; a root two tiles tall instead doubles it to 2π, giving e^(2π) = 535.49 and a cut at 89.786°. Each is one exponential and each was available.

The index is the geometry

The three integers can be folded into one string. At each level a tile is one of four quadrants of its parent, so the path from the root is a sequence of digits 0 to 3 — the quadkey, which is the bits of xx and yy interleaved.

That representation is not a naming convenience. It makes a geometric question into a string question: a tile is inside another exactly when its key extends the other’s. Testing containment, which is four floating-point comparisons on rectangles, becomes testing a prefix. Every parent of a tile is a prefix of its key, and the parents come out in order.

The site’s gate checks both directions of that claim over sixty-four tiles at level six and every one of their ancestors: the key round-trips to the tile it names, and the rectangle it names is contained in every rectangle its prefixes name. The check is worth having because the property is inherited from two other facts — the world is square, and each level is an exact quartering — and a scheme that had drifted on either would still produce keys that looked right.

Two routes to a tile’s extent

A tile’s rectangle can be computed two ways, and the site computes both.

The closed form divides the world by 2z2^z and multiplies by the indices, which is what a program does. The subdivision starts from the whole world and halves it zz times, following the bits of xx and yy, which is what the pyramid means. Over forty tiles at level 8 the two agree to 3.7×1093.7\times10^{-9} metres — floating-point noise on a coordinate of twenty million.

Agreement to that tolerance is not a formality. It is the statement that the scheme really is a quadtree over the projected plane rather than an indexing convention laid on top of one, and it is the kind of check the fleet’s own habit demands: two independent routes to the same number, or neither is believed.

The doubling is a claim about the projection

The exactness of the doubling is easy to read as arithmetic — of course halving a square gives half the width — but it carries a condition that is not arithmetic at all: the projection must not depend on the zoom level.

That is not a foregone conclusion. A scheme could reasonably choose a different projection for each level, and there is a good cartographic argument for it: the projection best suited to the whole world is not the one best suited to a single city, and every printed atlas ever made switches projection between its world map and its city plans. A scheme that did so would produce better-shaped maps at every level and would destroy the pyramid, because a tile at level 12 would no longer be four tiles at level 13 — it would be four tiles of a different map, computed independently, sharing no pixels and no cache.

So the scheme’s single projection is a consequence of the data structure rather than a cartographic judgement, and it is the reason a slippy map behaves the way it does: zooming in changes nothing but the scale, and the shape of a coastline arriving at level 14 is the shape that was already there at level 4, magnified. That continuity is what makes the interaction feel like moving a lens over a map rather than fetching a series of different maps, and it is bought at the cost of using one projection everywhere, including the two places where it is worst — the poles, which are cut off, and any measurement, which is wrong by the factor below.

The number that is not a distance

Here is where the scheme stops being merely a convention and starts misleading.

The published resolution — 38.2 metres per pixel at level 12 — is a distance in projected metres. On a Mercator projection the scale factor is secφ\sec\varphi, so the ground distance a pixel covers is smaller by cosφ\cos\varphi:

rground(z,φ)=r(z)cosφr_{\text{ground}}(z, \varphi) = r(z)\cos\varphi

At 51.5° north that is 23.8 metres rather than 38.2. At 60° it is 19.1, exactly half the published figure. The table is not wrong; it is a table of a projected quantity, published without a latitude column, and read as ground distance by everyone including the people who write specifications against it.

Metres per pixel, published and on the ground, zoom 0 to 18. The scheme's own resolution, and what a pixel is worth on the ground at four latitudes. Every level is exactly half the one above, so the published line is straight on a logarithmic axis and any two levels differ by a power of two. The ground curves are the same line lowered by log cos φ: at 75° a pixel covers 3.9 times less ground than the table says, so a reader there is looking at a map 3.9 times larger in scale than the one asked for.
Fig. 3 The published resolution and the ground resolution at four latitudes, on a logarithmic axis because the quantity halves at every level. The published line is straight by construction. The others are the same line lowered by log cos φ, and the gap between them is a factor of two by 60° and nearly four by 75°.

What the factor does to a stated scale

Turning metres per pixel into “1:50,000” needs one more convention: how large a pixel is on paper. The standard rendering pixel is 0.28 millimetres, which is 90.7 dots per inch, and nothing measures it — it is a number agreed on so that two programs can report the same scale for the same picture.

With it, level 12 is 1:136,495 at the equator. At 60° north the same picture is a 1:68,765 map. A reader who asks for a scale and is given a zoom level is being given a number that is true along one line of the Earth, which is the subject of the scale of a screen map is not one number.

What "1:136,495" means at each latitude, at zoom 12. A screen map at zoom 12 prints one scale for the whole world. The curve is how much larger in scale the map really is, measured from the projection's own derivatives rather than from a formula: at 60° it is 1.98 times, so the map labelled 1:136,495 is a 1:68,765 map. The hollow marks are sec φ, the textbook answer. They do not sit on the curve — the worst gap is 9949 parts per million at 85° — because Web Mercator puts a geodetic latitude into a spherical formula, and the same spherical Mercator measured the same way reproduces sec φ exactly.
Fig. 4 The scale a zoom level really is, against the one it prints, measured from the projection’s own derivatives. The hollow marks are sec φ, which is what a textbook gives, and they do not sit on the curve: the worst gap is 9,949 parts per million at 85°, because Web Mercator applies a spherical formula to a geodetic latitude.

The projection in the scheme is the site’s own headline

That last gap deserves its own sentence, because it is this site’s founding result arriving in a place nobody looks for it.

The scheme’s projection applies spherical Mercator formulae to geodetic latitudes read off the WGS84 ellipsoid. That is not a small approximation with a small consequence: it is what makes the projection non-conformal, measured at 0.3848° of maximum angular deformation against a noise floor of 1.6×1061.6\times10^{-6} for genuinely conformal projections — the argument of Web Mercator is not conformal.

Here the same defect shows up as a discrepancy in scale. The relative scale at 60° is 1.985 rather than 2.000, a departure of 7,522 parts per million from secφ\sec\varphi. The control that makes that a measurement rather than an artefact of differencing is in the same figure: the spherical Mercator, measured by identical machinery, reproduces secφ\sec\varphi to under 10210^{-2} parts per million.

Seven thousand parts per million is 7 metres per kilometre. Nothing on a screen map at continental zoom cares. A survey chain that has just spent four corrections getting to a centimetre, as in what a tape measures, cares a great deal, and the two worlds meet whenever survey data is put on a web map.

Where a pixel stops being a place

A pixel is not a point. It is a square of ground with a size, and every vertex drawn into it is moved to its centre.

The move is at most half a pixel in each direction, so at most half a diagonal in total: 16.8 metres at level 12, 1.05 at level 16, 0.13 at level 19. What that costs is not obvious in either direction — the displacement is smaller at high latitude, because the pixel covers less ground there, which is the opposite of what the stretched-looking map suggests.

One pixel at zoom 11: 76.4 m projected, 47.6 m at 51.5°. The grid squares are pixels, at their own size. The open mark is the stored coordinate and the filled one is where it is drawn: rounding moves it 20.2 metres, against a worst case of 33.6 — half a pixel's diagonal, which is the whole of the bound. The second point sits 43 metres away, 0.58 of a pixel east and 0.70 north, so whether the two are drawn as one dot or two is decided by where the tile grid happens to fall: they merge for 12 per cent of the possible offsets, against the 12 per cent the two fractions predict.
Fig. 5 The grid squares are pixels, at their own size. Rounding the stored coordinate to one moves it 9.6 metres here, against a bound of 16.8 — half a pixel’s diagonal. The second point is 43 metres away, and whether the two are drawn as one dot or two is decided by where the tile grid happens to fall.

That last observation is the pixel is a place with a size, and it is a genuinely odd property of the scheme: whether two things appear as two things is not a function of the data at all.

What a tile does not know

A tile is rendered from the geometry inside it. That is what makes the scheme scale — a request touches one square of the world and nothing else — and it is also its most visible failure, because a feature that crosses a boundary is drawn twice by two renderers that cannot see each other.

The consequence is measurable. Clipping a rectangle spanning Europe to the nine tiles it crosses at level 4 gives nine pieces whose areas sum to the whole to a relative 2×10162\times10^{-16} — the clipping is exact — and whose centroids are up to 1,863 kilometres from the whole feature’s. A label placed at each piece’s centroid is nine labels, none of them where the feature’s centre is. A tile is drawn without its neighbours takes that apart.

A feature across nine tiles at zoom 4, and the nine labels it gets. A rectangle from -10° to 30° east and 36° to 62° north, drawn in the projected plane with the tile boundaries over it. A renderer that draws each tile from the geometry inside that tile puts the label at the centroid of the piece, marked hollow; the whole feature's centroid is the filled mark. The furthest piece's label is 1863 kilometres from it. The pieces' areas sum to the whole to 2.2e-16 of a relative part, so the clipping is exact and the displacement is the operation rather than an error in it.
Fig. 6 One feature, nine tiles, nine labels. The pieces are exact — their areas sum to the whole — and their centroids are not the whole’s, by up to 1,863 kilometres. The displacement is bounded by the size of the feature rather than by the size of a tile, so it grows as the reader zooms out.

The exponential also explains why no cut is a comfortable one. Reaching an extra degree of latitude near the pole costs a multiplicative jump in the world’s height — from 85.05° to 89.79° is a factor of twenty-three in northing — so the choices available are not a smooth range to be traded against the area lost. They are a short list, each a power of two apart, and the area a scheme gives up falls much more slowly than the height it must accommodate rises.

What is convention and what is forced

It is worth separating the two, because the scheme is usually presented as one undifferentiated block of arbitrary choices.

Forced by the quadtree: a square projected world; an exact power-of-two relationship between levels; a cut at whatever latitude makes the world square, given the projection.

Conventions, and different schemes make them differently: the tile size in pixels — 256 or 512; the direction the row index counts, north-down in most schemes and south-up in one older one; the quadkey against three separate integers; the 0.28 mm rendering pixel.

And one that is neither: the projection. Nothing about a quadtree requires Mercator. What Mercator supplies is conformality — the property that a rotated or tilted view does not shear — and the usual argument, that a square world requires it, is simply false. There is a cylindrical equal-area projection whose world is exactly square, its standard parallels are at ±55.654°, and the pyramid did not have to be Mercator measures what choosing it would have cost instead.

Two square worlds: Mercator's areas against an equal-area scheme's angles. Both projections give a world exactly as wide as it is tall, so either could carry a quadtree of square tiles. Mercator keeps every angle and inflates area by sec²φ — 132-fold at 85°. The cylindrical equal-area scheme whose world is square has standard parallels at ±55.65° — the solution of π cos²φ₀ = 1 — and keeps every area exactly, at a cost of nothing there and 145° of angular deformation at the edges. At the standard parallel itself Mercator's areal factor is 3.142, which is π, because the square-world condition and sec²φ are the same equation.
Fig. 7 Both projections give a square world. Mercator keeps every angle and inflates area by sec²φ; the equal-area scheme keeps every area and shears. At the equal-area scheme’s own standard parallel, where it is undistorted, Mercator’s areal factor is exactly π — the same equation written twice, since the square-world condition is cos²φ₀ = 1/π.

The scheme as a coordinate system

Set against the site’s other coordinate systems, the tiling is unusual in one respect and ordinary in every other.

It is ordinary in that it is a projection with a stated ellipsoid, a stated origin and stated units, exactly as what a grid is made of requires of a national grid. Its false origin is the north-west corner rather than a point south-west of the country; its unit is the pixel rather than the metre; its scale factor is 1 on the equator rather than 0.9996 on a central meridian.

It is unusual in that the unit changes with the zoom. Every other coordinate system on this site has one unit for the whole system. Here a coordinate is only meaningful with a level attached, and the same ground is addressed by twenty different pixel coordinates depending on how closely it is being looked at. That is why a pixel coordinate is never stored: what is stored is degrees, and the pixel is computed at the moment of drawing — which is exactly the operation the rest of this field is about.

What the tiling scheme is good at

None of the above is an argument that the scheme is bad. It is an extremely good answer to the problem it solves, and the reason is worth stating in the same measured terms as the criticism.

A conformal projection means that the map looks locally correct at every point, at every zoom, in every direction of view. A square world means an exact quadtree. Powers of two mean no resampling. Between them those three give a scheme in which a request for any part of the world at any scale costs one lookup, in which the images are cacheable forever, and in which a reader dragging a map never sees a shape distort under the cursor.

What the scheme is bad at is being measured off — of areas, of distances, and of the scale it prints. Which is a way of saying that it made the trade every projection makes, and the rest of this field is about which operations land on the losing side of it. Every projection minimises something; this one minimises the cost of delivery.

Where this ladder goes next

The next rung takes the printed scale apart — what a zoom level means as a scale denominator, and why a single number for the whole world is not a simplification but a category error. After that comes the scale bar, which is the same problem in the form a reader can actually see, and then the cut at the top of the world, computed rather than quoted.

The measurements this essay rests on — the exact doubling, the containment property of quadkeys, the two routes to a tile’s extent, and the ground resolution at every latitude — are all in the site’s own gate, and every one of them is written so that it can fail.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

What links here

The 8 essays that link to this one and share the most of its objects, of 18 that link here.

The objects this essay names

Each one links to every other essay that touches it.

ConformalityConventionCoordinate reference systemGround resolutionQuadkeyScale factorTile pyramidToleranceVerificationWeb MercatorZoom level