Public
Edited
May 14, 2023
1 fork
51 stars
Kerkovits projectionA map of AfricaCupola ProjectionClipping spherical polygonsA conformal AiroceanFill with strokeMarkley’s tetrahedral map
Synchronized projections
Satellite GLSLVan Der Grinten IV GLSLVan Der Grinten III GLSLVan Der Grinten II GLSLWinkel Tripel GLSLLee Modified Stereographic GLSLMiller Oblated Stereographic GLSLModified Stereographic GS48 GLSLModified Stereographic GS50 GLSLFoucaut GLSLLagrange GLSLKavrayskiy VII GLSLEisenlohr GLSLEckert VI GLSLEckert V GLSLEckert IV GLSLEckert III GLSLEckert II GLSLEckert I GLSLBertin1953 GLSLRobinson GLSLMiller GLSLRectangular Polyconic GLSLPatterson GLSLPolyconic GLSLLoximuthal GLSLCylindrical Stereographic GLSLCylindrical Equal-Area GLSLTransverse Fahey GLSLFahey GLSLCollignon GLSLBromley GLSLBottomley GLSLHammer GLSLBonne GLSLBoggs GLSLBerghaus GLSLBaker Transverse GLSLBaker GLSLAugust GLSLAiry GLSLAitoff GLSLArmadillo GLSLLarrivée GLSLCylindrical Equal-Area GLSLAzimuthal Equidistant GLSLLittrow GLSLVan Der Grinten GLSLEquirectangular GLSLConic Conformal GLSLConic Equidistant GLSLAlbers GLSLConic Equal-Area GLSLEqual Earth GLSLTimes GLSLWagner IV GLSLWagner VI GLSLWagner VII GLSLWiechel GLSLAtlantis GLSLMollweide GLSLMercator GLSLTransverse Mercator GLSLCordiform GLSLWebMercator to globeVersor zooming for Three.jsAzimuthal Equal-Area GLSLBriesemeister GLSLRectilinear GLSLPhytoplanktonDanseiji projectionsTransverse MollweideThe 2D approximate Newton-Raphson methodInverting Lee’s Tetrahedral projectionAmerican PolyconicThe complex logarithm projectionRaster projection with GPU.jsH3 hexagons & geoContoursModified Stereographic ProjectionsFisheye Conformal Map (Cox)Fisheye Conformal MapFisheye Conformal Map (Tetrahedral)Reproject elevation tiles — worldTransverse projectionsThe Imago projectionD3 ProjectionsImago Projection Distorsion AnalysisEPSG:5530Imago tilingCordiform map projections 💛💗💖MultiPolygon clippingThe Nicolosi Globular ProjectionFisheye GlobeHerbert Bayer’s Pacific OceanThe Behrmann projectionOronce Finé’s triangle projectionDa Vinci’s octant projectionThe Lotus projection (1958)The Voronoi projectionUsing proj4js with D3 and PlotMurphey Butterfly ProjectionEquateur & tropiquesVega projectionsMercator projection of a Mercator globeThe truth about the Mercator projectionOcean-centric Mollweide projectionBuckminster Fuller’s triangle transformationExperimental two world projectionsTobler’s hyperelliptical projection (1973)Jacques Bertin’s projection (1953)A map without Antarctica (Bertin1953 projection)Square Root Azimuthal projectionThe Log-Azimuthal projectionPeirce Quincuncial Projection, centered on the South PoleTranslucent Earth (Satellite projection)Lee’s conformal projection in a tetrahedronAirocean projectionCubic projectionsCox conformal projection in a triangleIcosahedral projectionsDodecahedral projectionThe Cahill-Keyes projection (1975)Polyhedral projections with d3-geo-polygonWagner customizable projectionParametrized Equal Earth ProjectionThe Hufnagel projection systemTissot's indicatrixAn equal-area projection for the cubic EarthBase map
Also listed in…
Geo
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// this is a very classic function to draw a globe, not much to see there except the call to "zoom"
globe = function(
projection,
title,
{ invalidation, visibility, width = 300, height = 300 } = {}
) {
const context = context2d(width, height),
path = d3
.geoPath()
.projection(
projection
.precision(0.1)
.fitSize([width - 4, height - 4], { type: "Sphere" })
)
.context(context);

projection.translate(projection.translate().map(d => d + 2));

function drawText(text) {
context.save();
context.translate(4, 14);
context.font = "bold 9pt sans-serif";
context.shadowBlur = 3;
context.strokeStyle = context.shadowColor = "white";
context.shadowOffs = 0;
context.strokeText(text, 0, 0);
context.fillText(text, 0, 0);
context.restore();
}

function draw() {
const r = projection.rotate();
context.clearRect(0, 0, width, height);
context.beginPath();
path(d3.geoGraticule10());
context.lineWidth = 0.25;
context.stroke();
context.beginPath();
path(land);
context.fill();
context.beginPath();
path({ type: "Sphere" });
context.lineWidth = 1.5;
context.stroke();

drawText(title);
}

return d3
.select(context.canvas)
.classed("globe", true)
.call(
zoom(projection, draw, {
target: context.canvas,
invalidation,
visibility
})
)
.on("pointerenter pointerdown pointerup", event => {
d3.select(event.currentTarget).style(
"cursor",
event.type === "pointerdown" ? "grabbing" : "grab"
);
})
.node();
}
Insert cell
// this is where the magic happens:
// we take the versor-zooming component (renamed vzoom),
// and wrap it with the synchronization logic
zoom = {
// a communication channel between the globes
const dispatch = d3.dispatch("zoom");

return function(projection, draw, { target, invalidation, visibility }) {
invalidation && invalidation.then(() => dispatch.on("zoom." + id, null));

const id = Math.random(),
s0 = projection.scale();
let willdraw = 0;
dispatch.on("zoom." + id, async function(r, z) {
projection.rotate(r).scale((d3.zoomTransform(target).k = z * s0));

// priority given to the map under the mouse
if (this == target) draw();
// debounce the other maps
else if (!willdraw++) {
if (visibility) await visibility();
await new Promise(r => setTimeout(r, 5)); // change from 5 to 200ms to see what happens
willdraw = 0;
draw();
}
});

const zoom = vzoom(projection).on("zoom.render", function() {
dispatch.call("zoom", this, projection.rotate(), projection.scale() / s0);
});

// do first draw *after* zoom is applied
Promise.resolve().then(() =>
dispatch.call("zoom", this, projection.rotate(), 1)
);

return Object.assign(zoom, { dispatch });
};
}
Insert cell
html`<style>canvas.globe { margin: 3px; }</style>`
Insert cell
d3 = require("d3@7", "d3-geo-polygon@1.8")
Insert cell
import { zoom as vzoom } from "@d3/versor-zooming"
Insert cell
land = {
const topo = await d3.json(
"https://unpkg.com/visionscarto-world-atlas@0.0.6/world/110m.json"
),
simpler = topojson.simplify(topojson.presimplify(topo), 0.5); // try 0 for slower maps
return topojson.feature(simpler, simpler.objects.land);
}
Insert cell
topojson = require("topojson@3")
Insert cell
Insert cell
// outside of Observable, replace by or import from
// https://github.com/observablehq/stdlib/blob/master/src/dom/context2d.js
context2d = DOM.context2d
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