Published
Edited
Jul 18, 2022
10 stars
Insert cell
Insert cell
{
const context = DOM.context2d(width, height);
yield context.canvas;
const path = d3.geoPath(projection, context);

const stream = await FileAttachment("UScounties.json").stream();

const reader = stream.pipeThrough(geojsonStream.parse()).getReader();

while (true) {
const { done, value: feature } = await reader.read();
if (done) break;
context.beginPath(), path(feature), context.stroke();
}
}
Insert cell
projection = d3
.geoAlbersUsa()
.scale(1272)
.translate([width / 2, height / 2])
Insert cell
width = 954
Insert cell
height = 600
Insert cell
d3 = require("d3-geo@1")
Insert cell
geojsonStream = require("geojson-stream-whatwg@1.0.1/dist/geojson-stream-whatwg.umd.js")
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