Public
Edited
Nov 3, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
textContent = FileAttachment("BART_System_2020.kml").text()
Insert cell
xml = new DOMParser().parseFromString(textContent, "text/xml")
Insert cell
// it is used to convert xml to GeoJSON format
tj = require("https://unpkg.com/@tmcw/togeojson")
Insert cell
bartMapCollection = tj.kml(xml) // get geoJSON
Insert cell
{
for (const obj of bartMapCollection.features) {
const stationName = obj.properties.name;
const numOfExits = exitMap.get(stationName);
// add a new attribute to each station
obj.properties.volume = numOfExits;
}
}
Insert cell
bartMapCollection
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
linksWithDirection = {
const edges = [];

for (const row of sheet1) {
// find the destination of this row
let destination = "";
for (const [key, value] of Object.entries(row)) {
if (key === "Station") {
destination = value.toString();
}
}

for (const [key, value] of Object.entries(row)) {
const entryStation = key.toString();

// ignore the edges that point to themselves
// i.e. get in and out from the same station
if (key !== "Station" && key !== destination) {
edges.push({
source: nameMap.get(entryStation) + "_S",
target: nameMap.get(destination) + "_T",
value: value
});
}
}
}

yield edges;
}
Insert cell
Insert cell
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