Public
Edited
Jul 13, 2023
1 fork
5 stars
Insert cell
Insert cell
{
// The width is set by Observable, to make this responsive (type F to go fullscreen)
// const width = 928;
const height = Math.ceil(width / 1.92);
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "max-width: 100%; height: auto;");

const x = d3.scaleLinear(d3.extent(geo.features, d => d.properties.Easting), [0, width]);
const y = d3.scaleLinear(d3.extent(geo.features, d => d.properties.Northing),[0, height]);

const projection = d3.geoTransform({
point: function(px, py) {
this.stream.point(x(px), y(py));
}
});
const path = d3.geoPath(projection);

svg.append("path")
.datum(geo)
.attr("fill", "lightgray")
.attr("stroke", "#333")
.attr("d", path);

return svg.node();
}
Insert cell
geo = FileAttachment("geo.json").json()
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