Public
Edited
May 30, 2024
Insert cell
Insert cell
Insert cell
pe = d3.json("https://cdn.jsdelivr.net/npm/latam-atlas@0.0.5/files/peru-100k.json")
Insert cell
departments = topojson.feature(pe, pe.objects.level2)
Insert cell
peruProjection = {
const scale = 2000
//return d3.geoMercator().scale(scale).translate([3/2 * scale, 30])
return d3.geoIdentity().reflectY(true).fitSize([size.width, size.height], departments)
}
Insert cell
Insert cell
Insert cell
Plot.plot({
width: size.width,
height: size.height,
title: "Perú",
projection: peruProjection,
marks: [
Plot.geo(departmentsMesh, { strokeOpacity: 0.5, }),
Plot.geo(nation_pe,),
Plot.tip(
departments.features,
Plot.pointer(
Plot.centroid({
title: (d) =>
"Departamento: " + d.properties.name
})
)
)
],
caption: "Departamentos de Perú"
})
Insert cell
districts = topojson.feature(pe, pe.objects.level4)
Insert cell
Insert cell
Plot.plot({
width: 800,
height: 600,
projection: peruProjection,
marks: [
Plot.geo(districtsMesh, { strokeOpacity: 0.3 }),
Plot.geo(departmentsMesh, { strokeWidth: 0.8, }),
Plot.geo(nation_pe, ),
Plot.tip(
districts.features,
Plot.pointer(
Plot.centroid({
title: (d) =>
"Distrito: " + d.properties.name
})
)
)
],
caption: "Distritos del Perú"
})
Insert cell
Insert cell
ec = d3.json("https://cdn.jsdelivr.net/npm/latam-atlas@0.0.5/files/ecuador-transverse_mercator-50k.json")
Insert cell
projection = d3.geoTransverseMercator()
.rotate([50, 55])
//.scale(1000)
// .translate([900, 0])
Insert cell
nation_ec = topojson.merge(ec, ec.objects.level2.geometries)
Insert cell
provinces = topojson.feature(ec, ec.objects.level2)
Insert cell
provincesMesh = topojson.mesh(ec, ec.objects.level2, (a, b) => a !== b)
Insert cell
Insert cell
Insert cell
//parishes = topojson.merge(ec, ec.objects.level4.geometries)
parishesMesh = topojson.mesh(ec, ec.objects.level4, (a, b) => a !== b && (a.id / 1000 | 0) === (b.id / 1000 | 0))
Insert cell
Plot.plot({
width: 800,
height: 500,
margin: 10,
projection: {type: "reflect-y", domain: nation_ec, },
marks: [
Plot.geo(parishesMesh, { strokeOpacity: 0.3}),
Plot.geo(provincesMesh, { strokeWidth: 0.5 }),
Plot.geo(nation_ec),
Plot.tip(
parishes.features,
Plot.pointer(
Plot.centroid({
title: (d) =>
"Distrito: " + d.properties.name
})
)
)
],
caption: "Ecuador y sus parroquias"
})
Insert cell
location
Insert cell
Insert cell
margin = ({ left: 20, right: 20, top: 20, bottom: 20 })
Insert cell
size = ({ height: 600, width: 800 })
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