Public
Edited
Jul 21, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topohelper
// direct call inside from() to avoid a deep copy
.from(
await get_departement(
dpt_settings.dpt,
dpt_settings.arr ? "COMMUNE_ARRONDISSEMENT" : "COMMUNE",
"topojson",
dpt_settings.year
)
)
.project({ proj: l93 })
.view({ tooltip: true, zoom: true })
Insert cell
Insert cell
Insert cell
Insert cell
geojsons = get_multiple_departement(
dpts_settings.dpt,
dpts_settings.arr ? "COMMUNE_ARRONDISSEMENT" : "COMMUNE",
"geojson",
dpts_settings.year
)
Insert cell
geo = to_single_geojson(geojsons)
Insert cell
/**
* Merge all features of an array of geojson and return a single geojson
*/
function to_single_geojson(geojsons) {
// extract features of each geojson
const all_features = geojsons.map((d) => d.features).flat();
// keep first geojson as model and replace it's features with all_features
return { ...geojsons[0], features: all_features };
}
Insert cell
Insert cell
topohelper
.fromGeojson(geo)
.project({ proj: l93 })
.view({ layer: "all", tooltip: true, zoom: true })
Insert cell
Insert cell
Insert cell
Insert cell
// Projection Lambert 93 (EPSG: 2154)
l93 = "+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"
Insert cell
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