Public
Edited
Oct 24, 2023
2 forks
2 stars
Also listed in…
30 Day Map Challenge
Insert cell
Insert cell
projection = d3.geoInterrupt(
d3.geoHomolosineRaw,
[[ // northern hemisphere
[[-180, 0], [-130, 90], [-90, 0]],
[[-90, 0], [-30, 90], [60, 0]],
[[60, 0], [120, 90], [180, 0]]
], [ // southern hemisphere
[[-180, 0], [-120, -90], [-60, 0]],
[[-60, 0], [20, -90], [100, 0]],
[[100, 0], [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 = FileAttachment("ocean.json").json()
Insert cell
d3 = require("d3-geo@3", "d3-geo-projection@4")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more