Published
Edited
Jun 25, 2021
Insert cell
Insert cell
md`*A final version of this notebook can be viewed on my blog [here](https://www.robinlinacre.com/flight_distance/).*`
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
total_flight_miles = d3.sum(selected_airports_with_distances, d => d.distance)
Insert cell
total_energy_usage = eu.flying.flying_miles_to_kwh(total_flight_miles)
Insert cell
kwh_to_kg_co2 = function(kwh) {
return kwh * eu.convert.per("kg_co2_from_jet_fuel/kwh");
}
Insert cell
tonnes_co2 = kwh_to_kg_co2(eu.flying.flying_miles_to_kwh(total_flight_miles)) /
1000
Insert cell
fmt_num = d3.format(",.0f")
Insert cell
fmt_num_round = d3.format(",.2r")
Insert cell
Insert cell
Insert cell
eu = require("@robinl/energy_usage@0.1.6")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more