Published
Edited
Aug 27, 2020
Importers
2 stars
Insert cell
Insert cell
projection = d3.geoInterrupt(
d3.geoMollweideRaw,
[[ // northern hemisphere
[[-180, 0], [-130, 90], [-90, 5]],
[[-90, 5], [-30, 90], [60, 5]],
[[60, 5], [120, 90], [180, 0]]
], [ // southern hemisphere
[[-180, 0], [-120, -90], [-60, -5]],
[[-60, -5], [20, -90], [90, -5]],
[[90, -5], [140, -90], [180, 0]]
]]
).rotate([-200, 0])
Insert cell
map = {
const context = DOM.context2d(width, height);
const path = d3.geoPath(projection, context);
context.save();
context.beginPath(), path(outline), context.clip(), context.fillStyle = "#fff", context.fillRect(0, 0, width, height);
context.beginPath(), path(ocean), context.fillStyle = "#b7ccbb", context.fill();
context.beginPath(), path(graticule), context.lineWidth = 0.5, context.globalAlpha = 0.2, context.stroke();
context.restore();
context.beginPath(), path(outline), context.strokeStyle = "#000", context.stroke();
return context.canvas;
}
Insert cell
height = {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline);
const dy = Math.ceil(y1 - y0), l = Math.min(Math.ceil(x1 - x0), dy);
projection.scale(projection.scale() * (l - 1) / l).precision(0.2);
return dy;
}
Insert cell
outline = ({type: "Sphere"})
Insert cell
graticule = d3.geoGraticule10()
Insert cell
ocean = topojson.feature(world, world.objects.ocean)
Insert cell
world = fetch("https://gist.githubusercontent.com/mbostock/6713736/raw/e9f894d6bb066b9398cfdccff0c26732d12b9ef7/topo.json").then(response => response.json())
Insert cell
topojson = require("topojson-client@3")
Insert cell
d3 = require("d3-geo@2", "d3-geo-projection@3")
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