Public
Edited
Feb 10
Paused
Importers
4 stars
Insert cell
Insert cell
version = "0.0.8"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// equivalent to Traffic.fromURL(url)
// with url: https://github.com/xoolive/traffic/data/samples/collections/quickstart.json.gz
quickstart = Traffic.fromSample("quickstart", "collections")
Insert cell
Insert cell
quickstart.table() // There are table views
Insert cell
// but also html views
viewof belevingsvlucht = {
const flight = await Flight.fromSample("belevingsvlucht");
return flight.view({ graticule: 0.5 });
}
Insert cell
Insert cell
// equivalent to Array.from(quickstart.iterate(600))
trajectories = Array.from(quickstart)
Insert cell
viewof sample = trajectories
// Get one trajectory with an Air France callsign
.find((flight) => flight.callsign.slice(0, 3) === "AFR")
.view()
Insert cell
sample.table()
Insert cell
Insert cell
sample.rollup({
start: (f) => f.start,
callsign: "callsign",
icao24: "icao24",
vrate_max: op.max("vertical_rate")
})
Insert cell
stats = Array.from(quickstart).map((flight) =>
flight.rollup({
start: (f) => f.start,
callsign: "callsign",
icao24: "icao24",
vrate_max: op.max("vertical_rate"),
altitude_mean: op.mean("altitude")
})
)
Insert cell
stats
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
feature = belevingsvlucht.feature()
Insert cell
{
const container = yield htl.html`<div style="height: 500px;">`;
const map = L.map(container, { scrollWheelZoom: false });
const layer = L.geoJSON(feature).addTo(map);
map.fitBounds(layer.getBounds(), { maxZoom: 9 });
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
"© <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);

// Add a marker for one airport
L.marker([airports.EHAM.latitude, airports.EHAM.longitude])
.addTo(map)
.bindTooltip(airports.EHAM.name);
L.marker([airports.EHLE.latitude, airports.EHLE.longitude])
.addTo(map)
.bindTooltip(airports.EHLE.name, { permanent: true });
}
Insert cell
Plot.plot({
width: 400,
projection: { type: "mercator", domain: feature, inset: 10 },
marks: [
Plot.geo(feature),
Plot.dot([airports.EHAM, airports.EHLE], {
x: "longitude",
y: "latitude"
}),
Plot.text([airports.EHAM, airports.EHLE], {
x: "longitude",
y: "latitude",
text: "name",
textAnchor: "start",
dx: 10,
dy: 5
})
]
})
Insert cell
Insert cell
Plot.plot({
projection: {
type: "mercator",
domain: d3
.geoCircle()
.center([airports.LFPG.longitude, airports.LFPG.latitude])
.radius(1.5)()
},
color: { legend: true },
marks: [
Plot.geo(
Array.from(quickstart)
.filter(
// We don't plot all flights, only after this time
(flight) =>
flight.stop > d3.utcParse("%Y-%m-%d %H:%M")("2021-10-07 13:30")
)
.map((flight) =>
flight.feature({
start: "start",
stop: "stop",
callsign: "callsign",
vrate_mean: aq.op.mean("vertical_rate")
})
),
{
stroke: (elt) => elt.properties.vrate_mean
}
),
Plot.dot([airports.LFPO, airports.LFPG, airports.LFPB], {
x: "longitude",
y: "latitude"
}),
Plot.text([airports.LFPO, airports.LFPG, airports.LFPB], {
x: "longitude",
y: "latitude",
text: "name",
textAnchor: "start",
dx: 10,
dy: -5
})
]
})
Insert cell
Insert cell
Plot.line(sample.data, {
x: "timestamp",
y: "altitude",
stroke: "steelblue",
strokeOpacity: 0.8
}).plot() // sample.chart({y: "altitude"}).plot()
Insert cell
Plot.plot({
marks: [
Plot.line(sample.data, {
x: "timestamp",
y: "altitude",
stroke: "steelblue",
strokeOpacity: 0.8
})
],
x: {
tickFormat: d3.utcFormat("%H:%M"),
label: "timestamp (UTC)"
},
marginLeft: 100,
width,
height: 300,
grid: true
})
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
topojson = require("topojson-client@3", "topojson-server@3", "topojson-simplify@3")
Insert cell
Insert cell
Insert cell
import { toc } from "@nebrius/indented-toc"
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