Published
Edited
Dec 31, 2019
2 forks
Importers
24 stars
Insert cell
Insert cell
jszip = require("jszip@3/dist/jszip.min.js")
Insert cell
Insert cell
archive = FileAttachment("ne_50m_admin_0_countries.zip")
.arrayBuffer()
.then(buffer => jszip.loadAsync(buffer))
Insert cell
Insert cell
shp = archive.file("ne_50m_admin_0_countries.shp").async("arraybuffer")
Insert cell
dbf = archive.file("ne_50m_admin_0_countries.dbf").async("arraybuffer")
Insert cell
Insert cell
shapefile = require("shapefile@0.6")
Insert cell
collection = shapefile.read(shp, dbf)
Insert cell
Insert cell
d3 = require("d3-geo@1")
Insert cell
{
const height = 500;
const context = DOM.context2d(width, height);
const projection = d3.geoEqualEarth();
const path = d3.geoPath(projection, context);
context.lineJoin = "round";
context.beginPath();
path(collection);
context.lineWidth = 0.5;
context.stroke();
context.beginPath();
path({type: "Sphere"});
context.lineWidth = 1.5;
context.stroke();
return context.canvas;
}
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