Public
Edited
Aug 19, 2023
9 stars
Insert cell
Insert cell
Insert cell
function walkOnSpheres(point, steps = 3) {
let closest;
while (steps--) {
// Find the closest point in the reference shapes (uses d3-geo-voronoi).
closest = vertices[voronoi.find(...point)];

// Pick a point at random on the circle centered on point
// and with a radius extending to closest. For this, we
// define a rotation centered on that point, with a random
// angle, and apply it to the closest point (uses attitude).
point = attitude.axis(point).angle(Math.random() * 360)(closest);
}
return closest;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
color = d3.scaleOrdinal(d3.shuffle(d3.quantize(d3.interpolateSpectral, 60)))
Insert cell
d3 = require("d3@7", "d3-geo-projection@4", "d3-geo-voronoi@2", "d3-geo-polygon@1.9")
Insert cell
attitude = require("attitude").then((d) => d())
Insert cell
voronoi = d3.geoVoronoi(vertices)
Insert cell
vertices = countries.features.flatMap((f, i) => {
const c = d3.geoCentroid(f);
return geoVertices(f, i).map((d) => [...d3.geoInterpolate(d, c)(0.03), d[2]]);
})
Insert cell
world = d3.json(
"https://unpkg.com/visionscarto-world-atlas@0.1.0/world/110m.json"
)
Insert cell
land = topojson.feature(world, world.objects.land)
Insert cell
countries = topojson.feature(world, world.objects.countries)
Insert cell
import { geoVertices, contains } from "@fil/distance-to-shore"
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more