Public
Edited
May 31, 2023
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
session = new MapdCon()
.protocol("https")
.host("metis.mapd.com")
.port("443")
.dbName("heavyai")
.user("admin")
.password("HyperInteractive")
.connectAsync()
Insert cell
Insert cell
df = session.queryDFAsync(`
SELECT
t1.origin,
t1.dest,
sample(t1.origin_lat) as origin_lat,
sample(t1.origin_lon) as origin_lon,
sample(t1.dest_lat) as dest_lat,
sample(t1.dest_lon) as dest_lon,
count(1) as ct
FROM flights_donotmodify t1
group by 1, 2 having ct > ${flight_ct}
order by ct desc
`)
Insert cell
Insert cell
flight_table = aq.fromArrow(df)
Insert cell
Insert cell
Insert cell
flts_from = flight_table.groupby('origin').rollup({ flts_from: op.sum('ct') })
Insert cell
flts_to = flight_table.groupby('dest').rollup({ flts_to: op.sum('ct') })
Insert cell
flight_cts = flts_from
.join(flts_to,['origin','dest']) //This is the Arquero way of saying flts_from.origin = flts_to.dest
.select(['origin','flts_from','flts_to']) //Nit - in relational algebra, this is usually a 'projection'
Insert cell
flight_cts.view(100)
Insert cell
Insert cell
airport_loc = flight_cts
.join(flight_table,['origin'])
.select(['origin','flts_from','flts_to','origin_lon','origin_lat'])
Insert cell
Insert cell
arclayer =
new deck.ArcLayer({
id: `arcLayer`,
data: flight_table.objects(),
pickable:true,
autoHighlight:true,
getSourcePosition: d => [d.origin_lon, d.origin_lat],
getTargetPosition: d => [d.dest_lon, d.dest_lat],
getSourceColor: d => [255,128,0]
});
Insert cell
pointlayer =
new deck.ScatterplotLayer({
id: `pointlayer`,
data: airport_loc.objects(),
opacity: 1,
filled: true,
autoHighlight:true,
pickable: true,
radiusScale: 3,
radiusMinPixels: 1,
radiusMaxPixels: 100,
getPosition: d => [d.origin_lon, d.origin_lat],
getRadius: d => Math.sqrt(d.flts_from),
getFillColor: d => [128, 128, 0],
getLineColor: d => [0, 0, 0]
});
Insert cell
Insert cell
deckgl.setProps({layers:[pointlayer, arclayer]});
Insert cell
Insert cell
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