Cartogram pipeline · placement

How 50 states find their places

Each state is resized until its area matches its seat count, then moved into a hand-drawn slot, then pushed apart until nothing touches. Step through it below — the map is the real geometry the build produces, not a diagram of it.

Frame
States50 · one rigid body each
Largest scale
Smallest scale

    Why the collision test is the whole problem

    Once states are sized to their seat counts they collide, and something has to push them apart. Every reasonable solver does roughly the same thing; what decides the outcome is what you call a collision. Measured over the same 1,225 state pairs:

    Collision testPairs it flagsStates movedResult
    One circle per state (d3.forceCollide) 80 Demands 117px of separation. The country comes apart.
    One box per state (rectangle cartogram) 3437 of 50 Tennessee ends up between Kentucky and North Carolina.
    The outlines themselves 12–4 Correct, but the gap is whatever falls out.
    A chain of discs along each outline 13–11 Correct, and the gap is a number you set.

    California is why. It is a diagonal sliver whose bounding circle has a 148px radius against a 155px width, so a circle test believes it collides with half the West. Its bounding box overlaps Nevada's while the shapes come nowhere near each other.

    Where placement sits in the build

    Placement is one stage of a longer pipeline. mapshaper owns anything topological — projection, simplification, dissolve, polygon intersection. Base R owns everything numerical, with no packages beyond what ships with R.

    census boundaries project + simplify scale to seats place in slots push apart carve into cells match cells to districts JSON

    The three highlighted steps are what this page covers. Everything downstream — subdividing each state into equal-area district cells, matching those cells to real districts — happens inside the shapes once they have stopped moving.