Public
Edited
May 13, 2024
Paused
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topohelper.from(topojson, {deep: true})
Insert cell
Insert cell
Insert cell
Insert cell
lines = topohelper.from(topojson, {deep: true})
.lines()
Insert cell
Insert cell
Insert cell
innerlines = topohelper.from(topojson, {deep: true})
.innerlines()
Insert cell
Insert cell
innerlines_2 = topohelper.from(topojson, {deep: true})
.innerlines({groupby: "ADM1_PCODE"})
Insert cell
Insert cell
Insert cell
outerlines = topohelper.from(topojson, {deep: true})
.outerlines()
Insert cell
Insert cell
Insert cell
merge = topohelper.from(topojson, { deep: true }).merge({
groupby: "ADM1_PCODE"
})
Insert cell
Insert cell
Insert cell
filter = topohelper.from(topojson, {deep: true})
// All ADM-2 of Sofia and Sofia City ADM-1
.filter({condition: d => ["BG020", "BG021"].includes(d.properties.ADM1_PCODE)})
Insert cell
Insert cell
Insert cell
centroids = topohelper.from(topojson, {deep: true})
.centroids({better})
Insert cell
Insert cell
Insert cell
Insert cell
simplify = topohelper.from(topojson, {deep: true})
.simplify({level})
Insert cell
Insert cell
Insert cell
Insert cell
properties = topohelper.from(topojson, { deep: true }).properties({
select: ["ADM2_PCODE", "ADM2_EN", "Shape_Area"],
rename: { ADM2_PCODE: "id", ADM2_EN: "name", Shape_Area: "area" },
derive: { area_1000: (d) => d.area * 1000 }
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fourLayers.view({
layer: form.layer,
zoom: form.zoom,
tooltip: form.tooltip,
size: [form.width, form.width * 0.5]
})
Insert cell
Insert cell
Insert cell
fourLayers.toTopojson()
Insert cell
fourLayers.toTopojson({layer: [0,3]})
Insert cell
Insert cell
fourLayers.toGeojson()
Insert cell
fourLayers.toGeojson({layer: [0,3]})
Insert cell
Insert cell
properties.toObjects()
Insert cell
Insert cell
Insert cell
Insert cell
// Bulgaria administrative level 2
// https://data.humdata.org/dataset/cod-ab-bgr
topojson = FileAttachment("bgr_adm2_2022.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