Published
Edited
Jan 27, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
projection = d3.geoMercator().fitExtent([[0,0],[width,height]],province_geojson)
Insert cell
Insert cell
Insert cell
zipped = {
mutable loaded = 1;
return FileAttachment("24_hours_train_gps_7_jan_2022@1.csv.zip").zip();
}
Insert cell
raw_trains = {
mutable loaded = 2;
return zipped.file("24_hours_train_gps_7_jan_2022.csv").csv()
}
Insert cell
Insert cell
// { [time_string] : { [train_number] : { proj, time, lat, long, org, type, nr } }
trainSnapshots = {
const total = raw_trains.length;
const ret = {}
for (const obj of raw_trains) {
(ret[obj.time] || (ret[obj.time]={}))[obj.nr] =
{proj:projection([Number(obj.long),Number(obj.lat)]), ...obj};
}
mutable loaded = 3;
return ret;
}
Insert cell
// tracks the phase of data processing to show waiting notice
mutable loaded = 0;
Insert cell
Insert cell
Insert cell
raw_stations = FileAttachment("stations.csv").csv()
Insert cell
Insert cell
stations = raw_stations.map(r => ({proj:projection([r[0],r[1]]), ...r}));
Insert cell
Insert cell
Insert cell
province_geojson = FileAttachment("provincie_2022.geojson").json()
Insert cell
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