Published
Edited
Apr 26, 2021
Insert cell
md`# single point has no extent`
Insert cell
function fit_extent(data) {
const p = d3.geoMercator()
p.fitExtent(
[[0,0],[500,500]],
data
)
const s = p.scale()
const t = p.translate()
return `scale: ${s}\ntranslate: ${t}`;
}
Insert cell
// single point, extent computation no good
fit_extent({"type": "Feature", "geometry": {"type": "Point", "coordinates": [4.8885, 52.4039]}})
Insert cell
// multi point, extent computation just fine
fit_extent({"type": "Feature", "geometry": {"type": "MultiPoint", "coordinates": [[4.8885, 52.4039], [5.8885,53.4039]]}})
Insert cell
d3 = require("d3@6")
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