Plot.raster(
airports,
Plot.geoCentroid({
fill: 1,
interpolate: function (index, width, height, X, Y, V) {
const quadtree = d3.quadtree()
.x((i) => X[i])
.y((i) => Y[i])
.addAll(index);
const R = new Float32Array(width * height);
for (let x = 0; x < width; ++x) {
for (let y = 0; y < height; ++y) {
const i = quadtree.find(x, y);
R[x + y * width] = Math.hypot(X[i] - x, Y[i] - y);
}
}
return R;
}
})
).plot({
projection: "albers-usa",
color: { scheme: "Cool", legend: true, domain: [0, 15], clamp: true }
})