Public
Edited
Sep 3, 2022
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
landPaths = {
// cf. https://observablehq.com/@nbremer/simplified-curved-earth-map

// TopoJSONの簡略化

let japan_simplified = topojson.presimplify(japan);
let min_weight = topojson.quantile(japan_simplified, quantileValue);
japan_simplified = topojson.simplify(japan_simplified, min_weight);

let land_simplified = topojson.merge(
japan_simplified,
japan_simplified.objects["prefectures"].geometries
);

// SVGパスのカーブ化

const svgPath = path(land_simplified).split("M");
svgPath.shift();

let land_rounded = [];
svgPath.forEach((d) => {
land_rounded.push(
d
.replace(/Z/, "")
.split("L")
.map((p) => p.split(","))
);
});

function curvedPath(land, curveFunc) {
const line = d3
.line()
.x((d) => d[0])
.y((d) => d[1])
.curve(curveFunc);
return land.map((d) => line(d));
}

const landPaths = {
無し: path(land_simplified),
curveBasisClosed: curvedPath(land_rounded, d3.curveBasisClosed),
curveCatmullRomClosed: curvedPath(land_rounded, d3.curveCatmullRomClosed),
curveNatural: curvedPath(land_rounded, d3.curveNatural)
};

return landPaths;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
japan = FileAttachment("prefectures.json").json()
Insert cell
Insert cell
Insert cell
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