Cartogram studio
The same cartogram, solved in your browser instead of in R. Change a parameter and it re-solves: states are rescaled to their seat count, dropped into their slots, pushed apart until nothing overlaps, carved into equal-area cells, and the cells matched back to districts. How each step works →
Drives everything downstream — each state's size and its number of cells.
The area divisor. Lower makes every state bigger, so the map fills more of the frame — and collides sooner.
The gap the relaxation enforces between any two states. Zero skips relaxation and leaves them in their slots.
More points means a better area estimate and a slower solve. The R build uses 600.
The sampling is the only randomness. Same seed, same cells.
- placement
- —
- carving
- —
- matching
- —
- vs. the R build
- —
What is actually running here
Projection, simplification and dissolve are mapshaper's, done once — those
are the topological operations, and they are baked into the state outlines
this page loads. Everything numerical is redone live by
web/solver.js: the seat-proportional rescaling, the
boundary-disc relaxation, uniform sampling, k-means, the capacity-balanced
power diagram, and the Hungarian assignment. It is a port of the R code,
and it is checked against it — sh/12_test_solver.js confirms
the assignment finds the same optimum R does and that the relaxation leaves
no two states closer than the padding.
Two honest caveats. First, cells here are the raw convex polygons; the
browser clips them to the state outline at paint time with an SVG
clipPath rather than intersecting the geometry as mapshaper
does. Identical on screen, but not true clipped geometry — exact areas and
exported files come from the R build. Second, this will not land on
pixel-identical positions to that build. The relaxation is a Gauss–Seidel
iteration, which is chaotic: a difference of 10⁻¹³ in the first pass grows
by roughly a factor of ten per iteration. Every run is a valid re-solve,
not a reproduction. What holds either way is the invariant — no two states
closer than the padding you asked for.