Measuring distortion

Measuring instead of naming

A projection is called conformal because that is its name. Running the definition as a computation over several hundred points takes about twenty lines, catches a projection the whole internet uses, and is almost never done.

Open any atlas, any textbook, any cartography library’s documentation. The projections are described as conformal, or equal-area, or neither. The descriptions are almost always right, and they are almost never checked.

They do not have to be taken on trust. Both properties are statements about a quantity computable at every point, so testing them is a loop.

Every projection in the library, measured against both propertiesMaximum angular deformation across the bottom, maximum areal error up the side, both on logarithmic scales and both measured over several hundred sample points rather than taken from the projection's description. Conformal projections lie on the left edge, equal-area ones along the bottom, and the corner where both vanish is empty because a projection there would be an isometry of the sphere onto the plane.10⁻⁶10⁻⁴10⁻²110010⁻¹¹10⁻⁸10⁻⁵10⁻²1010000maximum angular deformation / degreesmaximum areal errornothing here, everMercatorStereographicWeb MercatorGall–PetersMollweideEquirectangulartolerances: 0.0001° and 0.00000121 projections measured
Fig. 1 Every projection in this site’s library run through both tests. Angular deformation across the bottom, areal error up the side, both measured rather than declared. Twenty of the twenty-one behave as their names promise. One does not, and it is the one carrying most of the maps on the internet.

The whole method

A projection is a pair of functions taking longitude and latitude to xx and yy. Differentiate them and the four partials give the two principal scale factors, aa and bb, at any point.

Then:

  • conformal means a=ba = b, so the maximum angular deformation ω\omega is zero
  • equal-area means ab=1ab = 1, so the areal factor is one

Sample a few hundred points across the projection’s domain, compute both, and take the worst. If the projection claims conformality and the worst ω\omega is not zero, the claim is false.

That is it. There is no subtlety and no cleverness, which raises the question of why it is not standard practice — and the answer seems to be that everyone assumes somebody else did it.

The tolerance is the hard part

The measurement is easy. Deciding what counts as zero is not, because the derivatives are numerical and numerical derivatives have noise.

The wrong way to handle that is to pick a tolerance that makes the tests pass. The right way is to measure the noise, measure the smallest real defect, and check that the tolerance sits between them with room on both sides.

For this site:

  • The genuinely conformal projections — spherical Mercator, ellipsoidal Mercator, stereographic, Lambert conformal conic — measure between 1.21.2 and 1.6×1061.6\times10^{-6} degrees. That is the noise floor.
  • The smallest genuine failure is Web Mercator at 0.38480.3848 degrees.
  • The tolerance is 10410^{-4} degrees: about sixty times above the noise, about four thousand times below the failure.

Both margins are asserted on every build. A tolerance loosened enough to certify Web Mercator as conformal would itself fail the check, which is the property that makes the number defensible rather than convenient.

The equal-area side is cleaner. Areal error is a determinant and does not involve subtracting two nearly equal quantities, so the equal-area projections measure between 6×10126\times10^{-12} and 1.5×1091.5\times10^{-9} — three orders of magnitude quieter than the angular measurements, for a structural reason worth understanding rather than a lucky one.

The assertions must reject

An assertion that has quietly stopped rejecting is worse than no assertion, because everything downstream is written as though it were working.

So the gate does not only require the conformal projections to pass. It requires:

  • Web Mercator to fail the conformality test
  • Mercator to fail the equal-area test
  • Mollweide and Gall–Peters to fail the conformality test
  • the equirectangular projection to fail both

If any of those started passing, something would be broken — and it would be broken silently, because every figure would still draw a perfectly plausible map.

Tissot's indicatrix across MollweideA small circle on the sphere, drawn where the projection puts it. The dashed circle behind each is what an undistorted map would show. On Mollweide ω reaches 75°, and the areal factor reaches 1.0.dashed: an undistorted circledrawn in Mollweide
Fig. 2 Mollweide’s indicatrices. Every ellipse has the same area, which the equal-area test confirms to a part in 10¹¹. None of them is a circle except at two points, which is why the conformality test must reject it — and does.

Two routes to every number

Where a check can be done twice by independent means, it is.

The scale factors are computed by numerically differentiating the projection. For the four projections with simple closed forms — Mercator, equirectangular, sinusoidal, Lambert cylindrical — the analytic scale factors are also implemented, and the two must agree. They do, to better than 3×10113\times10^{-11}.

That check caught a real error during construction. The sinusoidal projection’s meridian scale factor is 1+λ2sin2φ\sqrt{1 + \lambda^2\sin^2\varphi}, and the first version of the analytic formula was written with latitude where longitude belongs. The projection’s meridians fan out from the central one, so a point far to the east is stretched along the meridian regardless of its latitude — and writing that as a function of latitude alone gives a curve of the right general shape and the wrong values. The numerical route disagreed by 0.48, and nothing about any drawn map would have looked wrong.

What a measurement catches that a name does not

Three things, in increasing order of how much trouble they cause.

A projection whose description is wrong. Rare in published sources and not unknown, particularly for the less common projections where the description has been copied from somewhere without anyone re-deriving it.

A projection implemented wrongly. Common. A transcribed formula with a sign error or a swapped argument produces a map that looks like a map. Every projection here is required to round-trip — forward then inverse returning the starting coordinates — and the twenty-one currently do so to 2×10152\times10^{-15} or better, but the Hammer projection’s inverse was wrong on the first attempt and only that check noticed.

A projection whose description is right about the sphere and wrong about the body being mapped. This is Web Mercator, it is the interesting case, and it is the one a name can never catch — because the name is accurate about the formula and the formula is being applied to the wrong thing.

How Mercator distorts, by latitudeAngular deformation and areal scale plotted against latitude along the meridian at 0°. On Mercator the angular deformation reaches 0.0° and the areal factor reaches 91.5.-60°-30°30°60°angular deformation, to 2°areal factor, to 91.5×latitudetwo independent distortionsalong the 0° meridian
Fig. 3 Mercator measured rather than described. The angular deformation lies flat on zero, which is what conformal means and is here a measurement rather than a restatement of the projection’s name. The areal factor is the price.

The same discipline elsewhere

This method is not specific to projections, and the sibling sites in this collection apply the same idea to whatever their subject makes checkable — a chemistry site that computes the contour an orbital picture claims to enclose, a colour site that verifies two patches captioned identical really are.

The common shape is this: find the claim that every figure in the field makes and nobody verifies, then verify it. The claims worth attacking are the ones where a wrong answer looks exactly like a right one, because those are precisely the ones inspection cannot catch.

In cartography that claim is the projection’s own name.

What the round-trip test catches

The conformality and equal-area assertions test a projection’s claimed property. A third assertion tests something more basic, and it is the one that fails most often during development.

Forward then inverse must return the starting coordinates. All twenty-one projections here do, to 2×10152\times10^{-15} or better.

The Hammer projection did not, on the first attempt. Its inverse had been transcribed from a reference with a scaling that did not match the forward formula this site uses, and the error was 1.55 radians — enormous, and completely invisible, because nothing on the site called the inverse for that projection at the time.

The fix was to derive the inverse rather than transcribe it. Hammer is exactly the Lambert azimuthal equal-area projection applied to half the longitude with the x coordinate doubled, so its inverse is Lambert’s inverse on half the x with the longitude doubled back. Written that way the relationship is visible and the scaling cannot be got wrong.

HammerThe graticule of the Hammer projection at 30° of longitude and 15° of latitude. equal-area, and the meridians curve so the poles are points. It is equal-area.equal-areadrawn in Hammer
Fig. 4 The Hammer projection, whose inverse was wrong until a round-trip assertion caught it. Nothing about this picture would have looked different with the broken inverse, because drawing a map only uses the forward direction.

That is the general shape of the problem this site exists to address. The error was in a code path no figure exercised, in a projection whose forward map was correct, and it would have surfaced eventually as a wrong answer in some later essay with no indication of where it came from.

Sampling, and why worst-case

The audit takes the worst value over its sample points rather than the mean, and the choice matters.

Conformality is a statement about every point. A projection that is perfectly conformal over ninety per cent of its domain and badly wrong over the rest is not conformal, and an average would report it as nearly so.

The sampling is 24 longitudes by 17 latitudes, skipping points outside the projection’s valid domain — the poles for Mercator, the far hemisphere for the azimuthals. That is around four hundred points per projection, which is enough to find any region of failure large enough to matter and not enough to find a pathology confined to a single point.

That last limitation is real and worth stating. A projection with an isolated singularity between sample points would pass, and the site’s assertions would not catch it. What protects against that in practice is that projections are smooth almost everywhere and their failures are regional rather than pointlike.

How Winkel tripel distorts, by latitudeAngular deformation and areal scale plotted against latitude along the meridian at 0°. On Winkel tripel the angular deformation reaches 78.0° and the areal factor reaches 4.4.-60°-30°30°60°angular deformation, to 78°areal factor, to 4.4×latitudetwo independent distortionsalong the 0° meridian
Fig. 5 Winkel tripel sampled at one-degree intervals along a meridian. Both distortions vary smoothly, which is typical — a projection’s distortion is a smooth function of position, and a coarse sample finds the shape of it reliably.

What this does not check

Three things, and naming them is part of the discipline.

Whether the projection is the one it claims to be. The library’s Mercator could be some other conformal projection entirely and every assertion would pass. What guards against that is the round-trip test against published coordinates and the analytic scale-factor comparison, neither of which is a complete identification.

Whether the region of validity is right. A projection’s limit is declared rather than derived, and a wrong limit would exclude points that should be tested.

Whether the metric is right. Web Mercator’s whole defect only appears when measured against the ellipsoid; measured against a sphere it is perfectly conformal. Choosing the wrong metric would hide the very thing the site’s headline result depends on, and nothing in the machinery would notice.

That third one is the deepest limitation here. The assertions verify a projection against a stated model of the body being mapped, and if the model is wrong the verification is answering the wrong question correctly.

The errors this method found

Four, during the construction of this site, and all four were invisible in any drawn output.

The sinusoidal analytic scale factor was written as a function of latitude when it depends on longitude. Disagreement with the numerical route: 0.48.

The Hammer inverse was transcribed with a scaling that did not match the forward map. Round-trip error: 1.55 radians.

The rhumb-line generator interpolated latitude and longitude linearly, which produces a different curve entirely. It bowed on Mercator by nearly one per cent, and Mercator renders true rhumb lines exactly straight.

The spherical area formula summed longitude differences without wrapping them, so a ring encircling the globe cancelled to zero. A hemisphere came out with area zero.

Not one of those would have produced an obviously wrong picture. The first three would have produced slightly wrong numbers in captions, and the fourth would have produced a zero somewhere downstream that looked like a missing feature rather than a broken formula.

Cape Town to London on MercatorTwo routes. The great circle is 9671 km and is the shortest path on the sphere. The rhumb line holds a single compass bearing the whole way and is 9674 km — 3 km further, or 0.0 per cent. On Mercator the rhumb line departs from straight by 2.0e-7 of its own length.Cape TownLondonsolid: shortest · dashed: constant bearing+0.0% for the rhumbdrawn in Mercator
Fig. 6 Cape Town to London, the nearly north–south route where the great circle and the rhumb line almost coincide — three kilometres apart out of 9,671. A route like this one is where a broken rhumb generator hides best, because the two curves agree regardless.

What a tolerance should be made of

The general principle, since it applies well beyond this subject.

A tolerance has two jobs: absorb the noise, and catch the defect. Both are measurable, so a tolerance is defensible when the measurements bracket it and indefensible when it was chosen to make a test pass.

Reporting the margins alongside the tolerance is what makes the difference visible. This site’s conformality tolerance sits sixty times above the noise floor and four thousand times below the smallest real failure, and both figures are asserted rather than stated — so a future change that narrowed either margin would fail the build rather than silently weakening the test.

Every projection in the library, measured against both propertiesMaximum angular deformation across the bottom, maximum areal error up the side, both on logarithmic scales and both measured over several hundred sample points rather than taken from the projection's description. Conformal projections lie on the left edge, equal-area ones along the bottom, and the corner where both vanish is empty because a projection there would be an isometry of the sphere onto the plane.10⁻⁶10⁻⁴10⁻²110010⁻¹¹10⁻⁸10⁻⁵10⁻²1010000maximum angular deformation / degreesmaximum areal errornothing here, everMercatorStereographicWeb MercatorGall–PetersMollweideEquirectangulartolerances: 0.0001° and 0.00000121 projections measured
Fig. 7 The measurement the tolerance sits inside. The conformal projections cluster at the far left at 10⁻⁶ degrees; the failures are at 10⁻¹ and above; the tolerance is the boundary between them and it has four orders of magnitude of clearance on the side that matters.

What was computed here

The audit samples 24 longitudes by 17 latitudes across each projection’s valid domain, skipping points the projection cannot represent, and takes the worst case of each quantity rather than the mean. Worst case, because conformality is a statement about every point and an average would let a projection with one catastrophic region pass.

The derivatives use Richardson extrapolation over two step sizes, which cancels the leading error term. That was not enough on its own to move the noise floor much — the dominant error is roundoff rather than truncation at this step size — but it makes the floor stable across projections, which is what the tolerance argument needs.

The invariance check is the subtlest of the assertions. The principal scales, areal factor and angular deformation must not change when the projection’s output axes are swapped, while hh and kk exchange places. That is the cleanest demonstration available that the first group describes the map and the second describes the coordinates, and it comes out at exactly zero drift.

What the pictures cannot show

The audit plot’s axes span seventeen decades logarithmically, which is the only way to fit a noise floor of 101110^{-11} and a failure of 10410^{4} into one figure. Logarithmic axes compress differences, so the visual distance between two points understates how different they are, and the numbers should be read rather than the gaps.

The measurement itself is also invisible. Nothing in any drawn map shows whether it was verified, which is the entire problem this essay is about — and the only remedy is for the caption to carry the number.

Who found it, and when

Tissot supplied the local analysis in 1859 and 1881, so the tools have existed for a century and a half.

What has changed is that the arithmetic is now free. Computing ω\omega at five hundred points was a serious undertaking with a table of logarithms, and the pressure to derive properties analytically once and quote them thereafter was overwhelming. The analytical derivations are correct; the practice of quoting rather than checking outlived the constraint that justified it.

Modern geospatial libraries carry projection metadata — PROJ’s database records whether each is conformal or equal-area — as declared attributes rather than tested ones. The declaration is right in essentially every case, and Web Mercator is the exception that shows what the declaration cannot do.

Where this goes next

The tool underneath is Tissot’s indicatrix. The case this method found is Web Mercator is not conformal. And the theorem that says what the audit will always look like is the trade-off is two lines.