Public
Edited
Nov 11, 2023
Insert cell
Insert cell
raw = FileAttachment("foodFootprints.csv").csv()
Insert cell
data = raw.map(row => {
return {
name: row.Entity,
group: classificationsRaw[row.Entity],
em_kg: getValue(row, 'Emissions per kilogram'),
em_kcal: getValue(row, 'Emissions per 1000 kilocalories', 1000),
em_gprotein: getValue(row, 'Emissions per 100 grams of protein', 100),
em_gfat: getValue(row, 'Emissions per 100 grams of fat', 100),
land_kg: getValue(row, 'Land use per kilogram'),
land_kcal: getValue(row, 'Land use per 1000 kilocalories', 1000),
land_gprotein: getValue(row, 'Land use per 100 grams of protein', 100),
land_gfat: getValue(row, 'Land use per 100 grams of fat', 100),
eutro_kg: getValue(row, 'Eutrophication per kilogram'),
eutro_kcal: getValue(row, 'Eutrophication per 1000 kilocalories', 1000),
eutro_gprotein: getValue(row, 'Eutrophication per 100 grams of protein', 100),
eutro_gfat: getValue(row, 'Eutrophication per 100 grams of fat', 100),
ww_kg: getValue(row, 'Water withdrawals per kilogram'),
ww_kcal: getValue(row, 'Water withdrawals per 1000 kilocalories', 1000),
ww_gprotein: getValue(row, 'Water withdrawals per 100 grams of protein', 100),
ww_gfat: getValue(row, 'Water withdrawals per 100 grams of fat', 100),
sww_kg: getValue(row, 'Water scarcity per kilogram'),
sww_kcal: getValue(row, 'Water scarcity per 1000 kilocalories', 1000),
sww_gprotein: getValue(row, 'Water scarcity per 100 grams of protein', 100),
sww_gfat: getValue(row, 'Water scarcity per 100 grams of fat', 100),
}
})
Insert cell
names = data.map(item => item.name)
Insert cell
classificationsRaw = FileAttachment("classifications.json").json()
Insert cell
function getValue(data, key, factor = 1) {
const num = Number(data[key]);
return num === null ? null : num / factor
}
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