Public
Edited
Mar 18, 2024
Insert cell
Insert cell
map(sledgehammer().rotate([-11.25, 0, 0]))
Insert cell
md`The exact formula, based on [Strebe (2018)](https://www.mapthematics.com/Downloads/comAn_efficient_technique_for_creating_a_continuum_of_equal_area_map_projections_AM.pdf)’s technique:

${tex.block`\begin{aligned}
\text{Sledgehammer}(\lambda, \varphi) &= \mathrm{p}(\mathrm{h}^\prime[\sqrt{\tfrac{1}{2}} \cdot \mathrm{h}(\lambda, \varphi)])\text{, where} \\
\mathrm{h}(\lambda, \varphi) & \text{ refers to the Hammer projection,} \\
\mathrm{h}^\prime(x, y) & \text{ refers to its inverse, and} \\
\mathrm{p}(\lambda, \varphi) &= \left( \frac{8}{9} \cdot \frac{3}{\pi} \lambda, \sqrt{\frac{4}{3}} \sin \varphi \right)
\end{aligned}`}

To invert:

${tex.block`\text{Sledgehammer}^\prime(x, y) = \mathrm{h}^\prime \left( \sqrt{2} \cdot \mathrm{h}\left[ \frac{9}{8} \cdot \frac{\pi}{3} x, \arcsin \left( \sqrt{\frac{3}{4}} y \right) \right] \right)`}

And, finally, an equation describing the outer boundary of the map:

${tex.block`\tan^2 \left( \frac{3}{16}\pi x \right) = 3 - 3y^2`}`
Insert cell
sledgehammer = () => {
const sledgehammerRaw = (λ, φ) => {
const peters = (x, y) => [
(x * (8 / 9) * 3) / Math.PI,
Math.sin(y) * Math.sqrt(4 / 3)
];
const hammer = d3.geoHammerRaw(2, 2);

const hybrid = peters(
...hammer.invert(...hammer(λ, φ).map(t => t * Math.SQRT1_2))
);

return hybrid;
};

sledgehammerRaw.invert = (x, y) => {
const unpeter = (xp, yp) => [
xp * (Math.PI / 3) * (9 / 8),
Math.asin(yp * Math.sqrt(3 / 4))
];
const rehammer = d3.geoHammerRaw(2, 2);

const unhybrid = rehammer.invert(
...rehammer(...unpeter(x, y)).map(t => t * Math.SQRT2)
);

return unhybrid;
};

return d3.geoProjection(sledgehammerRaw);
};

Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more