Public
Edited
Dec 1, 2023
Importers
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
geoContainsCache = function(land) {
var w = 5000,
h = 5000,
projection = d3.geoAzimuthalEqualArea().fitSize([w, h], { type: "Sphere" }),
canvas = document.createElement("canvas"),
context = canvas.getContext("2d"),
path = d3.geoPath(projection, context);
canvas.width = w;
canvas.height = h;
context.fillStyle = "white";
context.fillRect(0, 0, w, h);
context.fillStyle = "black";
context.beginPath(), path(land), context.fill();
var c = context.getImageData(0, 0, w, h).data;
canvas = context = path = null; // free up memory
return function(point) {
point = projection(point);
return c[4 * (Math.floor(point[0]) + Math.floor(point[1]) * w)] < 128;
};
}
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