Published
Edited
Jun 22, 2021
Insert cell
Insert cell
{
var ods = [];

let odNew = {
orig: "S12000044",
dest: "S12000010",
flow: 2
};
ods.push(odNew);

let od = ods.find(od => od.orig === "S12000044" && od.dest === "S12000010");

console.log("OD flow is ", od.flow);

return od.flow;
}
Insert cell
odFile = await d3
.csv(
"https://raw.githubusercontent.com/gicentre/scrc/main/data/flows/scotLAsFlows.csv"
)
.then(objs => objs.map(o => Object.values(o).map(String)))
Insert cell
function getIDs() {
var myList = [];
var ods = [];

odFile.forEach((text, i) => {
const idO = String(text[0]);
const idD = String(text[1]);
const idZ = parseFloat(text[2]);

// -- keep a list of unique IDs:
if (!myList.includes(idO)) {
myList.push(idO);
console.log(i, idO);
}

// -- store the OD information:
let odNew = {
orig: idO,
dest: idD,
flow: idZ
};
ods.push(odNew);
});
// return myList;
return ods;
}
Insert cell
getIDs()
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