Published
Edited
Feb 10, 2019
2 forks
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
points = {
const ctx = DOM.context2d(width, height, 1)
//Set up the projections
const projection = d3.geoNaturalEarth1().fitWidth(width, {type: "Sphere"})
const path = d3.geoPath(projection, ctx)
//Create a land shape | Filter out Antarctica
const land = topojson.merge(world, world.objects.countries.geometries.filter(d => d.id !== "010"))

// Initialize the context’s path with the desired boundary (nothing is drawn to the screen yet)
ctx.beginPath()
path(land)

// Iterate over the grid and test whether points are inside
let points = []
for (let y = size / 2; y <= height + size / 2; y += size) {
for (let x = size / 2; x <= width + size / 2; x += size) {
if (ctx.isPointInPath(x, y)) {
points.push({x: x, y: y, row: y})
}//if
}//for x
}//for y
return points
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
height = width/2
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