Published
Edited
Nov 3, 2021
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
antipodal = ({
type: "MultiPolygon",
coordinates: d3
.geoProject(land, d3.geoIdentity().reflectY(true).translate([180, 0]))
.coordinates.map((poly) => poly.map((ring) => ring.reverse()))
})
Insert cell
intersect = (A, B) => {
// clip on the plane
const p = d3.geoEquirectangular();
A = d3.geoProject(A, p).coordinates;
B = d3.geoProject(B, p).coordinates;
return {
type: "MultiPolygon",
coordinates: clip
.intersection(A, B)
.map((poly) => poly.map((ring) => ring.map(p.invert)))
};
}
Insert cell
intersection = intersect(land, antipodal)
Insert cell
Insert cell
d3 = require("d3@7", "d3-geo-projection@4", "d3-geo-polygon@1.8")
Insert cell
clip = require("polygon-clipping@0.15.3")
Insert cell
land = fetch("https://unpkg.com/visionscarto-world-atlas@0.0.6/world/110m_land.geojson")
.then(d => d.json())
.then((d) => d.features[0].geometry)
Insert cell
height = (740 / 928) * width
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