Published
Edited
May 8, 2021
Importers
11 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topology = (await fetch("https://cdn.jsdelivr.net/npm/world-atlas@2/land-50m.json")).json()
Insert cell
land = topojson.feature(topology, topology.objects.land)
Insert cell
Insert cell
height = {
const projection = createProjection().fitWidth(planeWidth, outline)
const [[x0, y0], [x1, y1]] = d3.geoPath(projection).bounds(outline);
return Math.ceil(y1 - y0) + (margin * 2);
};
Insert cell
createProjection = {
const meta = projections.find(d => d.name === name);
return d3[meta.propertyName];
}
Insert cell
planeWidth = width - (margin * 2)
Insert cell
Insert cell
outline = ({type: "Sphere"})
Insert cell
path = d3.geoPath(projection)
Insert cell
projection = createProjection().fitWidth(planeWidth, outline)
.translate([width / 2, height / 2])
Insert cell
graticule = d3.geoGraticule10() // meridians / parallels every 10°
Insert cell
Insert cell
d3 = require("d3@6", "d3-geo-projection@3")
Insert cell
topojson = require("topojson-client@3")
Insert cell
Insert cell
projectionsBySurface = projections.filter(d => (d.surface === surface) && !d.unsuitable);
Insert cell
projectionsBySurfaceAndMetric = {
if (metric === "Any") {
return projectionsBySurface;
}
return projectionsBySurface.filter(d => d.metrics !== undefined)
.filter(d => d.metrics.includes(metric));
}
Insert cell
projectionsBySurfaceMetricAndConstruction = {
if (construction === "Any") {
return projectionsBySurfaceAndMetric;
}
return projectionsBySurfaceAndMetric.filter(d => d.construction !== undefined)
.filter(d => d.construction.includes(construction));
}
Insert cell
html`<style>
label {
margin-right: 14px !important;
}

input {
margin-left: 1px;
}

#outline,
#graticule {
fill: none;
}

#outline {
stroke: #000;
}

#graticule {
stroke: #ccc;
}
</style>`
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