Measuring distortion

A map drawn to a density it was handed

Two hundred and twenty-six essays measure distortion after the fact. This one specifies it: a density is handed to a map as a boundary condition, the areal scale factor comes out equal to it to five parts in a million, and every other invariant the site owns becomes the price.

Everything in this collection treats distortion as a cost. It is measured, ranked, apportioned, bounded and blamed; four of this field’s anchors are four ways of pricing it and the whole of the choosing field is two ways of minimising it. The two ways a map is wrong sets the frame and every essay since has worked inside it: a projection is given, its derivatives are taken, and the numbers that come out are the damage.

Nothing here has ever asked for a distortion.

A cartogram does. It is a map whose areal scale factor is handed to it — so much page area per unit of something, region by region — and whose only job is to meet it. That inverts the site’s apparatus in a way that turns out to be productive rather than merely cute. The areal factor stops being an output and becomes a boundary condition, and every other invariant becomes the price.

Four cities, met — the triangular, x first construction. Every cell drawn here holds the same area of ground and a different area of page: the map has been constructed so that its areal scale factor is the density it was handed, cell by cell, over a contrast of 25.99 to one. The residual against that target is 5.1e-6, measured from the map's own derivatives rather than from the construction. What it cost is the shape: the redistribution alone reaches 139.1° of angular deformation and averages 70.4°, on top of whatever the equal-area projection under it was already doing.
Fig. 1 A map of the sphere whose areal scale factor is a stated density rather than a consequence of a formula. Every cell drawn holds the same area of ground and a different area of page, in the proportion the density asks for. The residual against that target, measured from the map’s own four partial derivatives rather than from the construction, is five parts in a million.

The density is stated, not loaded

A cartogram of population needs population data, and this site does not take datasets — an area is a claim about a surface and a dataset’s surface is a vendor’s. The reason is the coastline decision this collection made early on: a dataset carries a generalisation level the reader cannot see, so a figure computed from one is partly a measurement of somebody’s vendor and the reader cannot tell how much.

For a cartogram that mistake would be made twice over, because the numbers would then be doing the arguing. A reader shown a population cartogram is being told two things at once — that some places are crowded, and that a map can be built to say so — and the second is the only one a projection collection can defend.

So the density here is a stated function: a floor plus a few smooth bumps at named places, with a sharpness that is a parameter. Its total mass over the sphere is a closed form,

S2eκ(cosγ1)dA=2πR21e2κκ,\int_{S^2} e^{\kappa(\cos\gamma - 1)}\,\mathrm{d}A = 2\pi R^2\,\frac{1 - e^{-2\kappa}}{\kappa},

so every quadrature below can be checked against arithmetic rather than against itself. Every figure names its density in the same breath as it names its projection, which is the site’s oldest habit applied to a second input.

Four cities, the density this cartogram is asked for. The stated density drawn on the equal-area map it is defined over, one panel of ink per cell of equal ground area, so the shading is a density and not a total. It is a sum of four bumps on a floor of 0.2, running from 0.200 to 5.197 — a contrast of 25.99 to one — with a total mass of 6.7021 on the unit sphere, which is a closed form rather than a sum over these cells. Nothing has been deformed yet: this is what the map is about to be told to do.
Fig. 2 The density this map is asked for, drawn on the equal-area projection it is defined over — one panel of ink per cell of equal ground area, so the shading is a density and not a total. It runs from 0.20 to 5.20 over the sphere, a contrast of 25.99 to one, and its total mass is a number in closed form rather than a sum over these cells.

The reduction that makes this cheap

A cartogram is usually presented as a hard numerical problem. It is only hard while the sphere is still in it.

The Lambert cylindrical projection carries the sphere to the rectangle x=λx = \lambda, y=sinφy = \sin\varphi, and its Jacobian determinant is exactly cosφ\cos\varphi — which is exactly the sphere’s own area element. So ground measure on that rectangle is dxdy\mathrm{d}x\,\mathrm{d}y, uniformly, and the fact that a cell of latitude and longitude has a closed-form area becomes the statement that the rectangle is a fair sheet of paper.

A cartogram of the sphere is therefore a map of that rectangle to itself whose Jacobian determinant is a prescribed function. The sphere never appears again.

That is worth stopping on, because it is the same move the site makes everywhere and it is easy to miss here. What survives a change of coordinates is the reason it works: the areal factor is an invariant, so a construction that gets it right on the rectangle gets it right on the sphere, whatever coordinates the rectangle was reached through.

The construction, which needs no iteration

The triangular map — Knothe’s, and Rosenblatt’s before it — pushes any positive density to the uniform one by two nested one-dimensional problems.

Let σ(x,y)\sigma(x, y) be the density on the rectangle, normalised to integrate to one. Take its marginal in xx,

m(x)=σ(x,y)dy,m(x) = \int \sigma(x, y)\,\mathrm{d}y,

and send xx to the position its cumulative marginal puts it at. Then, for each xx separately, send yy to the position its conditional cumulative puts it at. Two quadratures, no solve, no mesh, no convergence criterion.

The Jacobian is lower triangular, because the first coordinate of the answer depends only on the first coordinate of the argument, so its determinant is the product of the two diagonal entries:

uxvy=2πm(x)2σ(x,y)m(x)=4πσ(x,y).\frac{\partial u}{\partial x}\cdot\frac{\partial v}{\partial y} = 2\pi m(x)\cdot\frac{2\sigma(x, y)}{m(x)} = 4\pi\,\sigma(x, y).

The marginal cancels. The determinant is the density, times the total area, exactly — not to a tolerance, not after refinement, exactly, by the algebra of a cumulative distribution and its own derivative.

The same ground, before and after it is told what its areas must be. Above, the equal-area base: every cell carries the same area of ground and is drawn at the same area of page, which is what equal-area means. Below, the cartogram of four cities: the cells still carry the same area of ground and are now drawn at areas proportional to the density, to a residual of 5.1e-6. The deformation between the two panels is the whole content of the density, and the shading is identical in both.
Fig. 3 The same ground before and after it is told what its areas must be. Above, the equal-area base, where every cell of equal ground area is drawn at the same page area. Below, the cartogram, where the same cells are drawn at areas proportional to the density. The shading is identical in both panels; the deformation between them is the whole content of the request.

Reading it with the site’s own instruments

The point of the reduction is not that the arithmetic is easy. It is that the result is a projection like any other, and the machinery that reads a projection does not know or care where it came from.

distortion() takes an object with a forward method, differences it four ways, and returns hh, kk, aa, bb, the areal factor and ω\omega. It has never been shown anything but a formula. Handed a map defined by a pair of quadratures, it returns the same six numbers by the same route, and the areal factor it computes is a measurement of the drawn map rather than a restatement of the construction.

That distinction is the whole check. The construction says the determinant is 4πσ4\pi\sigma; the audit differences the map at 10410^{-4} radians and asks what the determinant actually is. If the two agree, the map is right and the arithmetic is right. If they disagree, one of them is wrong and the disagreement says which.

Every point of the map, against the density it was told to have. Each of the 408 points is one sample of the triangular, x first cartogram of four cities: along the horizontal axis the density it was given, up the vertical axis the areal scale factor computed from the map's own four partial derivatives. The line is equality. The largest departure anywhere is 4.50e-6, and the two quantities are reached by routes that share no arithmetic: one is the stated density, the other a Jacobian determinant of a map defined by quadrature.
Fig. 4 Every sample of the map, with the density it was handed along the horizontal axis and the areal scale factor computed from its own derivatives up the vertical. The line is equality. The largest departure anywhere is five parts in a million, and the two quantities are reached by routes that share no arithmetic.

They agree to 5×1065 \times 10^{-6}, which is the noise floor of a Richardson-extrapolated central difference on a function built from Simpson’s rule. There is nothing left over to report.

The density asked for and the density delivered, along 20° north. One parallel of the triangular, x first cartogram of four cities, with the requested areal scale factor drawn as the smooth curve and the value measured from the map's derivatives drawn over it. The two are indistinguishable at this scale; the largest disagreement anywhere along the parallel is 2.65e-6. The peaks are the bumps the density is made of, and their heights are the ratios the cartogram is enlarging by.
Fig. 5 One parallel of the same map: the requested areal scale factor and the value measured from the derivatives, drawn over each other. The peaks are the bumps the density is made of, and their heights are the ratios the map is enlarging by. The two curves are indistinguishable at this scale and everywhere else.

What it cost

A map has four derivatives at a point. Fixing the areal factor fixes one number, which is their determinant. Three degrees of freedom per point are left over, and the price of the request is where they land.

They land on the angle. Conformal means the two principal scale factors are equal, and nothing in the construction encourages that; the triangular map stretches hard in one direction and squeezes in the other wherever the density has a gradient.

What the density costs, along the same parallel. The angular deformation the redistribution itself adds, at 20° north on the triangular, x first cartogram of four cities, with the equal-area projection under it subtracted out. It peaks at 149.1° at -25° of longitude — on the FLANK of a bump rather than on its summit, because what costs shape is the density's gradient and not its value. Where the density is flat the cost is 71.63°.
Fig. 6 The angular deformation the redistribution adds along the same parallel, with the equal-area projection under it subtracted out. It peaks on the flank of a bump rather than on its summit, because what costs shape is the density’s gradient and not its value. Where the density is flat the redistribution costs nothing at all.

The peak is on the flank, and that is not a detail. A uniform density of any value is met by a uniform scaling, which is a similarity and has no angular deformation whatsoever. What deforms a map is the change in what is being asked for, so the worst places on a cartogram are the boundaries between the crowded and the empty — exactly the places a reader looks at hardest.

What the quadrature is checked against

The construction is two integrals and every number above depends on both of them, so the site’s usual question applies: how does anyone know the integrals are right?

Not by refining them, which only shows that a quadrature has converged to whatever it converges to. The mass of the density has a closed form, term by term, and it is reached by a substitution that has nothing to do with Simpson’s rule: for a bump eκ(cosγ1)e^{\kappa(\cos\gamma - 1)} on the unit sphere, writing t=cosγt = \cos\gamma turns the surface integral into 2π11eκ(t1)dt2\pi\int_{-1}^{1} e^{\kappa(t-1)}\,\mathrm{d}t, which is elementary. Summing over the bumps and adding the floor’s 4πb4\pi b gives the total.

A two-dimensional quadrature over the rectangle, at a resolution the construction never uses, agrees with that to three parts in a million. And it must disagree with the mass of a density it was not given, which is the half that makes it a check rather than a restatement: run the same comparison against another of the stated densities and it fails by more than a factor of two.

The same rule governs the tabulated cumulative marginal, which is the one place in the construction where a value is stored rather than computed. It is interpolated by a cubic Hermite whose end slopes are the exact marginal at each node — so the interpolant is continuously differentiable, its derivative is right at every node by construction, and the map’s own areal factor stays smooth across a cell boundary. A plain linear table was tried first and put a visible step into every measured aa and bb, at the grid spacing, which is exactly the signature a defect of that kind leaves.

Two numbers, not one

Reporting a single figure for the deformation of a cartogram is misleading, and the site nearly did it.

The map drawn above sits on top of the Lambert cylindrical rectangle, and that projection is already at 73.7° of angular deformation at 60° north and 133.0° at 78°, before any density has been applied. A total figure of 155° is therefore mostly a statement about the base map. So every measurement in this ladder reports two quantities: what the redistribution adds, computed from the Jacobian of the rectangle-to-rectangle map alone, and the total a reader actually sees.

For this density the redistribution alone reaches 139.1° at worst and averages 70.4° over the map. That is the number this anchor is about. The total is larger and belongs to a different argument — the one the equal-area cylindrical projections have been having since this collection began.

Every audit here therefore stops at 60° of latitude, and that is a decision about the instrument rather than about the map. The equal-area rectangle carries the poles to its own edges, where one degree of latitude occupies 1.5×1041.5 \times 10^{-4} of the rectangle’s height against 1.7×1021.7 \times 10^{-2} at the equator — so the last cell of any grid covers everything above about 78°, and a maximum taken over the whole sphere is a statement about one cell.

What a shape looks like on it

One ground shape, drawn at four places on the same cartogram. A circle of the same angular radius on the ground, drawn where each of these places falls on the triangular, x first cartogram of four cities, with each panel scaled to its own drawing so the shapes can be compared rather than the sizes. The ratio under each is the long axis over the short one, from the map's own derivatives: London 1.3, Quito 6.5, Tokyo 1.5, São Paulo 1.5. The areas are right by construction at all four, which is the only thing that is.
Fig. 7 A circle of the same angular radius on the ground, drawn where each of four places falls on the same cartogram, each panel scaled to its own drawing so the shapes can be compared rather than the sizes. The ratio under each is the long axis over the short one, read off the map’s own derivatives. The areas are right by construction at all four, which is the only thing that is.

This is Tissot’s indicatrix with the sign of the argument reversed. Ordinarily the ellipse is what the map does to a circle and the areal factor is one of the things it reports. Here the areal factor was fixed first and the ellipse is what was left; the same object, read from the other end.

The reading a cartogram invites

There is a further cost, and it is not in the derivatives at all.

The four numbers a projection reports at a point describe what happens to an infinitesimal circle there. They say nothing about what happens to a distance between two places, because a distance is an integral along a curve and the curve passes through many points with different numbers. A scale bar is right in one place makes that argument for an ordinary projection; on a cartogram it is far worse, because the areal factor was chosen to vary rather than allowed to.

Measured over twelve pairs of the named places, with the page scaled so that the median pair reads exactly right — the most generous calibration available — the worst pair on this map is out by 35 per cent. A reader with a ruler and the legend’s scale is not making a bad measurement of a distance; they are making a measurement of something that is not a distance.

That is the subject of the fourth rung and it is mentioned here because the temptation is to treat the shape cost as the whole price. It is not. The shape cost is what the derivatives report; the reading cost is what a reader does with the page, and the two are different sizes.

There are two triangular maps, and the construction picks one

The construction is asymmetric by design — it spends its whole correction in x and then repairs y conditionally — and the asymmetry has a consequence the essay’s own summary implies without stating: the same density has a second triangular map, obtained by doing y first.

That map is as exact as this one. The determinant argument does not care which coordinate is marginalised: take the marginal in y, push y to its cumulative, then push x to its conditional cumulative, and the two diagonal entries multiply to the same 4π σ. Two constructions, one request, both met to the arithmetic’s floor.

They are not the same map, and they do not cost the same. The shape damage is decided by where the stretching lands, and the two orders put it in different places: the x-first map is nearly rigid in y along any line where the density’s x-marginal is flat, and the y-first map is nearly rigid in x wherever the y-marginal is. On a density whose features are elongated in one direction — which is what a real one usually is, since coastlines and populated belts run somewhere — the two will differ, and nothing about the density says in advance which is better.

This ladder measures neither. It measures the x-first map, which is the one the reduction reaches first through the Lambert rectangle, and it reports a worst angular deformation of 139.1° and a mean of 70.4°. Whether the y-first map on the same density is better or worse is a single re-run of the same code and is not in these figures.

That is worth recording as owed rather than glossing, because it sharpens the shortfall in the section above. The triangular map is close to the worst member of the family is stated there as an expectation; the cheapest possible test of it is the other member of a pair the construction already contains, and the difference between the two is a lower bound on how much better the family’s best member is than this one.

There is a third thing in the same neighbourhood and it is free. A uniform density costs nothing — the map is then a similarity, with no angular deformation anywhere — so the whole cost is a functional of how the density varies rather than of what it is. Scaling a density by a constant changes nothing at all, since the normalisation removes it; scaling its contrast is what moves the cost. The 25.99-to-one contrast of the density used here is therefore the parameter the 139.1° belongs to, and quoting the deformation without it is quoting half a measurement.

Where the model stops

Three things this construction does not do, and each of them is a rung further up.

It is not the only map that meets the request. Compose it with any area-preserving map of the rectangle — a shear, a swirl, a second cartogram of a uniform density — and the result meets the same density exactly. There is a whole infinite-dimensional family, and the triangular map is one member chosen for being computable rather than for being good.

It is not the least distorted member of that family. It is close to the worst. The triangular construction spends its entire correction in xx first and then repairs yy conditionally, which is as asymmetric as a construction can be, and the shape cost shows it.

It is not what anybody publishes. Every implementation of the last twenty years computes a diffusion cartogram, which produces a picture a reader recognises and which does not meet its target exactly. The pairing between those two facts is the subject of the next rung.

Who found it, and when

The triangular construction is Rosenblatt’s, from a 1952 paper on transforming multivariate distributions, and Knothe’s, from a 1957 paper on convex bodies; neither was thinking about maps. That two statisticians and a geometer arrived at the same object is the usual sign that the object is the natural one, and the reason it works here is that a cartogram and a change of variables in a probability integral are the same problem written in different notation.

The existence result behind it is older and more general. Moser’s theorem — that any two smooth positive densities of equal total mass on a compact manifold are related by a diffeomorphism — says that the request is always grantable, whatever the density, and says nothing whatever about the cost. The whole of this ladder lives in that gap.

Where the ladder goes next

The request can always be met, so this anchor never asks whether a map exists. It asks which of the infinitely many maps that meet it was chosen, what that choice cost, what a discretisation of the choice does when it goes wrong, and what a reader who takes a ruler to the result is actually measuring.

The boundary against the condition ladder is exactly there. That anchor’s answer is sometimes no such map existsrung 7 is the essay in which a request is refused — and this one’s never is.

Named alongside this one

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

What links here

Every essay whose body links to this one.

The objects this essay names

Each one links to every other essay that touches it.

Angular deformationAreal factorBoundary conditionCartogramDensityEqual-areaJacobianLambert cylindricalPrincipal scale factorsQuadratureShape distortionTriangular map