Published
Edited
Sep 30, 2022
1 fork
12 stars
Insert cell
Insert cell
Insert cell
projection = d3
.geoPolyhedralVoronoi()
.parents(parents)
.polygons(polygons)
.angle(38)
.fitExtent([[0, 0], [950, 500]], { type: "Sphere" })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cost = {
return function(a, b) {
return d3.geoDistance(a, b) / (1 + 2 * (inland[a[2]] + inland[b[2]]));
};
}
Insert cell
Insert cell
Insert cell
Insert cell
parents = {
var n = points.length;

var links = voro.links().features.map(d => d.properties);

var k = kruskal(
links.map(
d => ((d.source.index = d.source[2]), (d.target.index = d.target[2]), d)
),
cost
).map(l => ({
type: "LineString",
coordinates: [l.source, l.target],
properties: l
}));

// Build a tree of the faces
var parents = [-1];
var search = n - 1;
do {
k.forEach(l => {
var s = l.properties.source[2],
t = l.properties.target[2];
if (parents[s] !== undefined && parents[t] === undefined) {
parents[t] = s;
search--;
} else if (parents[t] !== undefined && parents[s] === undefined) {
parents[s] = t;
search--;
}
});
} while (search > 0);

return parents;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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