Published
Edited
Apr 21, 2022
Insert cell
Insert cell
Insert cell
Insert cell
uSUpd.filter(d=>d.sub_region_2.match("Alameda"))
Insert cell
Plot.plot({
marks: [
Plot.line(uSUpdGroupMonth.filter(d=>d.area_code=== "Los Angeles, California")[0].data, {
x: "date",
y: "workplaces_percent_change_from_baseline",
curve:"basis"
})
]
})
Insert cell
Insert cell
Insert cell
uSUpd.filter(d=>d.sub_region_2==="Calhoun County")
Insert cell
uSUpd_tot.filter(d=>(d["rural"]===null))
Insert cell
// Plot.plot({
// marks: [
// Plot.line(ukUpdGroupMonth.filter(d=>d.area_code==="E06000050")[0].data, {
// x: "date",
// y: "workplaces_percent_change_from_baseline",
// curve:"basis"})
// ]
// })
Insert cell
// Plot.plot({
// x: {type: "log"},
// y: {domain: [-50, -10]},
// marks: [
// Plot.dot(ukUpd_tot, {
// x: d=>d["rural"],
// y: "workplaces_percent_change_from_baseline",
// })
// ]
// })
Insert cell
// Plot.plot({
// marks: [
// Plot.barY(urbRural_raw, {x: "RUC11", y: "column2"})
// ]
// })
Insert cell
// Plot.plot({
// marks: [
// Plot.rectY(urbRural_raw, Plot.binX({y: "sum"}, {x: "RUC11"}))
// ]
// })
Insert cell
Insert cell
hexes_UK.filter(d=>d.leCat==="London Commuter Belt"&&d.category==="#47a45b").length/hexes_UK.filter(d=>d.category==="#47a45b").length
Insert cell
// hexes_UK.filter(d=>d.leCat==="London's Larger Urban Zone"&&d.category==="#47a45b").length/hexes_UK.filter(d=>d.category==="#47a45b").length
Insert cell
hexesClean_US = makeCleanData("US", ruralDataUS, clusterDataUS)
Insert cell
hexesClean_UK = makeCleanData("UK", ruralDataUK, clusterDataUK)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
uSUpdGroupMonth = uSUpdGroup.map(d=> {return {
area_code: d.area_code,
data:
d3.rollups(d.data, v => //[
// d3.median(v, d => d.retail_and_recreation_percent_change_from_baseline),
// d3.median(v, d => d.grocery_and_pharmacy_percent_change_from_baseline),
// d3.median(v, d => d.parks_percent_change_from_baseline),
// d3.median(v, d => d.transit_stations_percent_change_from_baseline),
d3.median(v, d => d.workplaces_percent_change_from_baseline),
// d3.median(v, d => d.residential_percent_change_from_baseline)],
d => d.dateMonth).map(d=> { return {
date: d[0],
workplaces_percent_change_from_baseline: d[1]
}
}).sort((a,b)=>d3.ascending(a.date,b.date))
}
})
Insert cell
uSUpdGroup = d3.groups(
uSUpd.map(d=>({...d,
dateMonth:new Date(d.date.split("-")[0]+"-"+d.date.split("-")[1]),
dateWeek: new Date(d.date.split("-")[0]+"-"+d.date.split("-")[1]+ new Date(d.date).getWeekOfMonth()),
area_code: d.sub_region_2===null||d.sub_region_2===""?d.sub_region_2:
d.sub_region_2.replace(' County','')+", "+d.sub_region_1,
}))
,
v=>v.area_code)
.map(d=> { return {
area_code: d[0],
data: d[1]
}
})
Insert cell
Insert cell
Insert cell
Insert cell
uSUpd_tot = makeAggDataUs(uSUpd)
Insert cell
ukUpd_tot = makeAggData(ukUpd)
Insert cell
function makeCleanData(country, ruralData, clusterData) {
let hexesClean = country==="UK"?
hexes_UK.map(d=>({...d, mobilityWork: d.mobilityWork,
income: d.income,
vertices: null,
points: null,
x: d.x,
y: d.y,
category: d.category,
urbCategory: d.urbCategory,
leCat: d.leCat,
urbRow: d.urbCategory!==null &&
ruralData.filter(c=>c.urbCategory===d.urbCategory)!==undefined &&
ruralData.filter(c=>c.urbCategory===d.urbCategory)[0].data.filter(e=>e.LAD11CD===d.key)[0]!==undefined?
ruralData.filter(c=>c.urbCategory===d.urbCategory)[0].data.filter(e=>e.LAD11CD===d.key)[0].row:null,
catRow: d.category!=="#ccc"? clusterData.filter(c=>c.category===d.category)[0].data.filter(e=>e.key===d.key)[0].row:null,
leRow:leData.filter(c=>c.leCat === d.leCat)[0].data.filter(e=>e.key===d.key)[0]!==undefined?leData.filter(c=>c.leCat === d.leCat)[0].data.filter(e=>e.key===d.key)[0].row:null

}))
.map(d=>({...d,

paddingCatX: getPadding("UK","category", d.catRow, d.urbRow).x,
paddingCatY: getPadding("UK", "category", d.catRow, d.urbRow).y,
paddingUrbX: getPadding("UK","urbCategory", d.catRow, d.urbRow).x,
paddingUrbY: getPadding("UK", "urbCategory", d.catRow, d.urbRow).y,
paddingLeX: getPadding("UK","urbCategory", d.catRow, d.leRow).x,
paddingLeY: getPadding("UK", "urbCategory", d.catRow, d.leRow).y
// paddingCat: {x:getPadding("UK","category", d.catRow, d.urbRow, d.urbCategory).x,
// y:getPadding("UK", "category", d.catRow, d.urbRow, d.urbCategory).y},
// paddingUrb: {x:getPadding("UK","urbCategory", d.catRow, d.urbRow, d.urbCategory).x,
// y:getPadding("UK", "urbCategory", d.catRow, d.urbRow, d.urbCategory).y}
}))
:
hexes_US.map(d=>({...d, mobilityWork: d.mobilityWork,
income: d.income,
x: d.x,
y: d.y,
category: d.category,
urbCategory: d.urbCategory,
urbRow: d.urbCategory!==null &&
ruralData.filter(c=>c.urbCategory===d.urbCategory)!==undefined &&
ruralData.filter(c=>c.urbCategory===d.urbCategory)[0].data.filter(e=>e.fullName===d.fullName)[0]!==undefined?
ruralData.filter(c=>c.urbCategory===d.urbCategory)[0].data.filter(e=>e.fullName===d.fullName)[0].row:null,
catRow: d.category!=="#ccc"?clusterData.filter(c=>c.category===d.category)[0].data.filter(e=>e.fullName===d.fullName)[0].row:null,
}))
.map(d=>({...d,

paddingCatX: getPadding("US","category", d.catRow, d.urbRow).x,
paddingCatY: getPadding("US", "category", d.catRow, d.urbRow).y,
paddingUrbX: getPadding("US","urbCategory", d.catRow, d.urbRow).x,
paddingUrbY: getPadding("US", "urbCategory", d.catRow, d.urbRow).y
}))

return hexesClean
}
Insert cell
Insert cell
Insert cell
// function makeLondonEverywhereData()
// let londonEvData = hexes_UK.map(d=>({...d, leCat: codesLondon.includes(d.key)?"Greater London":"Not London"}))
// return londonEvData
// }
Insert cell
function makeLondonEverywhereData() {

let categoriesX = [colors[6], colors[2], colors[4], colors[7], colors[5], colors[3], colors[1], colors[0], colors[8]]

let sortOrder = [categoriesX[1], categoriesX[0], categoriesX[4], categoriesX[2], categoriesX[7], categoriesX[5], categoriesX[6],
categoriesX[3], categoriesX[8]]

// let leMap = hexes_UK.map(d=>({...d, leCat: codesLondon.includes(d.key)?"Greater London":"Not London"}))
let leData =
d3.groups(
hexes_UK
.filter(d=>d.category!=="#ccc")
.filter(d=>hexes_UK.map(d=>d.key).filter(onlyUnique).includes(d.key)), v=>v.leCat)
.map(d=> {
return {leCat: d[0], data: d[1].sort(function(a, b) {
return sortOrder.indexOf(a.category) - sortOrder.indexOf(b.category);
})//.sort((a,b)=> d3.descending(a.category,b.category))
.map((c, i) =>({ ...c, row: i}))
}
})

return leData
}
Insert cell
function makeRuralData(country) {

let categoriesX = country==="UK"?[colors[6], colors[2], colors[4], colors[7], colors[5], colors[3], colors[1], colors[0], colors[8]]:
[colors[2], colors[6], colors[7], colors[4], colors[3], colors[5], colors[8], colors[1], colors[0]] ;

let sortOrder = country==="UK"?[categoriesX[1], categoriesX[0], categoriesX[4], categoriesX[2], categoriesX[7], categoriesX[5], categoriesX[6],
categoriesX[3], categoriesX[8]]:
[categoriesX[0], categoriesX[1], categoriesX[5], categoriesX[3], categoriesX[8], categoriesX[4], categoriesX[7],
categoriesX[2], categoriesX[6]];
let ruralData = country==="UK"?
d3.groups(
ukUrbRural
.map(d=>({...d, category: hexes_UK.filter(c=>c.key===d.LAD11CD)[0]!==undefined?
hexes_UK.filter(c=>c.key===d.LAD11CD)[0].category:null
}))
.filter(d=>d.category!=="#ccc")
.filter(d=>hexes_UK.map(d=>d.key).filter(onlyUnique).includes(d.LAD11CD)), v=>v.RUC11)
.map(d=> {
return {urbCategory: d[0], data: d[1].sort(function(a, b) {
return sortOrder.indexOf(a.category) - sortOrder.indexOf(b.category);
})//.sort((a,b)=> d3.descending(a.category,b.category))
.map((c, i) =>({ ...c, row: i}))
}
}):
d3.groups(
hexes_US,
// .map(d=>({...d, category: hexes.filter(c=>c.key===d.LAD11CD)[0]!==undefined?
// hexes.filter(c=>c.key===d.LAD11CD)[0].category:null
// }))
// .filter(d=>hexes.map(d=>d.fullName).filter(onlyUnique).includes(d.fullName)),
v=>v.urbCategory
)
.filter(d=>d[0]!==null)
.map(d=> {
return {urbCategory: d[0], data: d[1]
.filter(d=>d.urbCategory!==null&&colors.includes(d.category)&&d.mobilityWork!==null&&d.income!==null).sort(function(a, b) {
return sortOrder.indexOf(a.category) - sortOrder.indexOf(b.category);
})//.sort((a,b)=> d3.descending(a.category,b.category))
.map((c, i) =>({ ...c, row: i}))
}
})

return ruralData
}
Insert cell
function makeAggDataUs(data, lkd=false) {
const data_tot = d3.rollups(
data,
v => [d3.median(v, d => d.retail_and_recreation_percent_change_from_baseline),
d3.median(v, d => d.grocery_and_pharmacy_percent_change_from_baseline),
d3.median(v, d => d.parks_percent_change_from_baseline),
d3.median(v, d => d.transit_stations_percent_change_from_baseline),
d3.median(v, d => d.workplaces_percent_change_from_baseline),
d3.median(v, d => d.residential_percent_change_from_baseline),
v[0].place_id,
v[0].sub_region_2===null?v[0].sub_region_2:
v[0].sub_region_2,//.replace(' County',''),
v[0].sub_region_1,
v[0].census_fips_code.length===4?"0"+v[0].census_fips_code:v[0].census_fips_code
],
d => d.place_id).map(([k, v]) =>
({
local_authority: k,
sub_region_1: v[8],
borough_abbr: v[7],//k===null?k:k.replace(' District','').replace('London Borough of ',''),
place_id: v[6],
area_code: v[9],
fullName: v[7] +", "+v[8],
// retail_and_recreation_percent_change_from_baseline: v[0],
// grocery_and_pharmacy_percent_change_from_baseline: v[1],
// parks_percent_change_from_baseline: v[2],
// transit_stations_percent_change_from_baseline: v[3],
workplaces_percent_change_from_baseline: v[4],
// residential_percent_change_from_baseline: v[5],
// tot_mobility: d3.median([v[0], v[1], v[3], v[4], v[5]]),
"Total annual income (£)":
usCountyIncome.filter(
c=>c.geoid===v[9])[0]===undefined?null:
usCountyIncome.filter(
c=>c.geoid===v[9])[0].income,

rural: urbRuralUs.filter(
c=>c.geoid===v[9])[0]===undefined?null:
urbRuralUs.filter(
c=>c.geoid===v[9])[0].pct_rural_2010,

urbCategory: urbRuralUs.filter(
c=>c.geoid===v[9])[0]===undefined?null:
urbRuralUs.filter(
c=>c.geoid===v[9])[0].urbCategory,
// x: hex_us.filter(c=>c.fullName === v[7] +", "+v[8])[0]===undefined?null:
// hex_us.filter(c=>c.fullName === v[7] +", "+v[8])[0].x,
// y: hex_us.filter(c=>c.fullName === v[7] +", "+v[8])[0]===undefined?null:
// hex_us.filter(c=>c.fullName === v[7] +", "+v[8])[0].y
})
)

return data_tot
}
Insert cell
function makeAggData(data, lkd=false) {
const data_tot = d3.rollups(
data,
v => [d3.median(v, d => d.retail_and_recreation_percent_change_from_baseline),
d3.median(v, d => d.grocery_and_pharmacy_percent_change_from_baseline),
d3.median(v, d => d.parks_percent_change_from_baseline),
d3.median(v, d => d.transit_stations_percent_change_from_baseline),
d3.median(v, d => d.workplaces_percent_change_from_baseline),
d3.median(v, d => d.residential_percent_change_from_baseline),
v[0].place_id,
v[0].sub_region_2===null?v[0].sub_region_2:
v[0].sub_region_2.replace(' District','').replace('London Borough of ','').replace("Royal Borough of ", ""),
v[0].sub_region_1,
],
d => d.place_id).map(([k, v]) =>
({
local_authority: k,
sub_region_1: v[8],
borough_abbr: v[7],//k===null?k:k.replace(' District','').replace('London Borough of ',''),
place_id: v[6],
area_code: loa_google.filter(
c=>c.place_id===v[6])[0]===undefined?null:
loa_google.filter(
c=>c.place_id===v[6])[0].lad19cd,
// retail_and_recreation_percent_change_from_baseline: v[0],
// grocery_and_pharmacy_percent_change_from_baseline: v[1],
// parks_percent_change_from_baseline: v[2],
// transit_stations_percent_change_from_baseline: v[3],
workplaces_percent_change_from_baseline: v[4],
// residential_percent_change_from_baseline: v[5],
// tot_mobility: d3.median([v[0], v[1], v[3], v[4], v[5]]),
"Total annual income (£)":
loa_google.filter(
c=>c.place_id===v[6])[0]===undefined?null:
incomeLOA.get(loa_google.filter(
c=>c.place_id===v[6])[0].lad19cd),

// pop: loa_google.filter(
// c=>c.place_id===v[6])[0]===undefined?null:
// popLOA.get(loa_google.filter(
// c=>c.place_id===v[6])[0].lad19cd),

rural: loa_google.filter(
c=>c.place_id===v[6])[0]===undefined?null:
urbRuralLOA.get(loa_google.filter(
c=>c.place_id===v[6])[0].lad19cd)
})
)

return data_tot
}
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
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
uSUpd_2021_1 = d3.csvParse(await FileAttachment("2021_US_Region_Mobility_Report_1@1.csv").text())
Insert cell
uSUpd_2021_2 = d3.csvParse(await FileAttachment("2021_US_Region_Mobility_Report_2.csv").text())
Insert cell
uSUpd_2020_1 = d3.csvParse(await FileAttachment("2020_US_Region_Mobility_Report_1.csv").text())
Insert cell
uSUpd_2020_2 = d3.csvParse(await FileAttachment("2020_US_Region_Mobility_Report_2.csv").text())
Insert cell
uSUpd = d3.merge([uSUpd_2021_1, uSUpd_2021_2, uSUpd_2020_1, uSUpd_2020_2])
Insert cell
Insert cell
usCountyIncome = {
let data = await FileAttachment("county_2019 - us_county_death_rate_2019(1).csv").csv();

let dataFinal = data.map(d=> { return {
geoid:d.fips,
income: +d.income,
}})
return dataFinal
}
Insert cell
Insert cell
ukUpd_2021 = d3.csvParse(await FileAttachment("2021_GB_Region_Mobility_Report_1213 (1).csv").text())
Insert cell
Insert cell
hex_us =
// d3.csv("https://gist.githubusercontent.com/lnicoletti/96e5574ab6d6b0e020487e0d660c24d6/raw/5b8416327fe7fef589de0101165209295e4a830a/usCountiesHex_obs.csv", d3.autoType)
// d3.csv("https://gist.githubusercontent.com/lnicoletti/6287798c66d526c134e91da1d289f1f3/raw/951a889c43268b4793f7ca5e9125cd76a07c2240/usCountiesHex_obs_2.csv", d3.autoType)
// d3.csv("https://gist.githubusercontent.com/lnicoletti/62ee1b2144ad7dbcd6a66eddbc1b0544/raw/6cd8ed474e719767f40e7de88e02b6815b1e0d03/usCountiesHex.csv", d3.autoType)
d3.csv("https://gist.githubusercontent.com/lnicoletti/a01622da3e106830fe1c51ab96403234/raw/2b0d35c4efff50a65beb29759ae1a55eb99f73ac/usCountiesHex_tilemaps_albers.csv")
Insert cell
hex_la = d3.json("https://raw.githubusercontent.com/odileeds/hexmaps/gh-pages/maps/uk-local-authority-districts-2021.hexjson")
Insert cell
loa_google = d3.csv("https://gist.githubusercontent.com/lnicoletti/75225f0d73379a2e655adba5c7ab2e73/raw/a9fc2eafef3ce111898f527933ee6a60de7c0e8c/loa_to_google.csv")
Insert cell
incomeLOA = new Map([...incomeLOA_map, ...incomeScot_map, ...incomeNI_map])
Insert cell
incomeNI_map = d3.rollup(incomeNI_raw, v => d3.mean(v, d => +d["Total annual income (£)"]), d => d["Local authority code"])
Insert cell
incomeLOA_map = d3.rollup(incomeLOA_raw, v => d3.mean(v, d => +d["Total annual income (£)"].trim().replace(",","")), d => d["Local authority code"])
Insert cell
incomeScot_map = d3.rollup(incomeScot_raw, v => d3.mean(v, d => +d["Total annual income (£)"]), d => d["Local authority code"])
Insert cell
incomeScot_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/0362b4f47cda3e21abfade570db5517c/raw/7328051a65edd71691cc6a129cbabe4586c97286/scotlandIncome.csv", d3.autoType)
Insert cell
incomeNI_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/47978c96e59de67c9bb263d54c746e76/raw/2f360795eb339debff580ec4d6d816a7ce8103cb/nIrelandIncome.csv")
Insert cell
incomeLOA_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/fb38b11e3ee566f5fc2dd4a8ee4a7fc4/raw/a37b54dc60d5a8f3297a9c83d6a5baa172193dc2/incomeestimatesforsmallareas.csv")
Insert cell
popLOA = d3.rollup(popLOA_raw, v => d3.mean(v, d => +d["Population density"]), d => d["LA code"])
Insert cell
engUrbRural = d3.csv("https://gist.githubusercontent.com/lnicoletti/9b5df10403fd89cc6af0ee8cd26b7925/raw/cacd508ed040a1d190401e9b16247b970181aac1/ukUrbRural_2class.csv", d3.autoType)
Insert cell
Insert cell
ukUrbRural = d3.merge([engUrbRural, scotUrbRural])
Insert cell
urbRuralLOA = d3.rollup(urbRural_raw, v => d3.mean(v, d => +d["Rural including hub towns (rural & rural related) population1 (%)"]), d => d["LAD11CD"])
Insert cell
// popLOA_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/80acb6ca345efd71a49f1e9a7e3855ad/raw/6d40d0f36f3d98eae534dca6cf100eb228317686/ukpopestimatesmid2020on2021geography.csv", d3.autoType)
Insert cell
popLOA_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/78a02c631de8767e69c672ce790a3b17/raw/7f44d1501c10a70e7362934193a9d6799d7d93d5/ukPopDen.csv", d3.autoType)
Insert cell
urbRural_raw = d3.csv("https://gist.githubusercontent.com/lnicoletti/7baf3e11996edb30a5fb590d3f76f7ef/raw/11a7c8f3ff3525e565776f9406facc2f793bede4/ukUrbRural.csv", d3.autoType)
Insert cell
incomeIt =
//https://lab24.ilsole24ore.com/mappaRedditi/redditiTabelle.html
d3.csv("https://gist.githubusercontent.com/lnicoletti/db9c74083db65ad219c9951a2a2709cf/raw/b55cb1e293f70d2467d9b5c7c8ac66a6c0a3cc1c/IT_income.csv", d3.autoType)
//https://www.infodata.ilsole24ore.com/2019/11/16/scopri-pil-pro-capite-delle-tua-provincia-misura-la-tua-ricchezza/
Insert cell
incomeFR = d3.csv("https://gist.githubusercontent.com/lnicoletti/6ce6ea0f0e834c1474229d979ceccba9/raw/2bb1c632e47834546ea357fb0aa8324853a03c46/FR_income.csv", d3.autoType)
//https://www.insee.fr/fr/statistiques/4508514#figure1_radio2
Insert cell
// https://opendata.cbs.nl/statline/#/CBS/nl/dataset/84639NED/table
incomeNL = d3.csv("https://gist.githubusercontent.com/lnicoletti/d186d92c1c186d525c45fa344daea662/raw/6f4b88b7ba98a73270c35f130eef24a0b6570a5f/NL_income.csv", d3.autoType)
Insert cell
incomeCA = d3.csv("https://gist.githubusercontent.com/lnicoletti/451413e33229d7f9b9c882a6a5eb129a/raw/c5af6d251e8582d068e8f83ce3d2b5cb2565541d/CA_income.csv", d3.autoType)
//https://www12.statcan.gc.ca/census-recensement/2016/geo/map-carte/ref/thematic-thematiques/inc-rev/map-eng.cfm?TYPE=1
Insert cell
incomeAU = d3.csv("https://gist.githubusercontent.com/lnicoletti/f3790a08faaea687f35bdb1bf83247f4/raw/1562aaa28cec29c8fe39cc5d12a69d1df254ce4d/AU_income.csv", d3.autoType)
//https://www.abs.gov.au/statistics/labour/earnings-and-work-hours/personal-income-australia/latest-release#data-download
// LGA TABLE 1.5
Insert cell
incomeDK = d3.csv("https://gist.githubusercontent.com/lnicoletti/780606be32f8e9d2a18afee9b2fe8589/raw/3b7d26afb49e93a10a736afc71aeaa7802a6eaa7/DK_income.csv", d3.autoType)
//https://www.statistikbanken.dk/statbank5a/SelectVarVal/saveselections.asp
Insert cell
incomeSE = d3.csv("https://gist.githubusercontent.com/lnicoletti/8f896198771fba0b3df1ba3e6177c3bc/raw/c13945b4709b56a1f59b031c1d38fe38a89bd41d/SE_income.csv", d3.autoType)
// https://www.scb.se/en/finding-statistics/statistics-by-subject-area/household-finances/income-and-income-distribution/income-and-tax-statistics/pong/tables-and-graphs/income--persons-counties-and-municipalities/total-income-from-employment-and-business-2000-and-20182020-by-municipality.-median-values-in-2020-prices/
Insert cell
incomeNO = d3.csv("https://gist.githubusercontent.com/lnicoletti/b666273df142d7ce3dbe72552be2952b/raw/94df2806ef4389cef0b793e1f9c56609c44504ce/NO_income.csv", d3.autoType)
// https://www.ssb.no/en/statbank/table/06944/tableViewLayout1/
Insert cell
incomeES = d3.csv("https://gist.githubusercontent.com/lnicoletti/58a2f55641c850ac4a0792681479b3df/raw/01d0cb14d2c0f961fdd6f77cd0390f9c3ce922ca/ES_income.csv", d3.autoType)
//https://es.wikipedia.org/wiki/Anexo:Provincias_de_Espa%C3%B1a_por_producto_interno_bruto_per_c%C3%A1pita
Insert cell
incomePT = d3.csv("https://gist.githubusercontent.com/lnicoletti/a137af23df1a49a3d48f4a6f0a26ee00/raw/c6a4b85213d63d1bd177e70371c6ec70600fd41f/PT_income.csv", d3.autoType)
// Rendimento bruto declarado médio por sujeito passivo
// https://www.ine.pt/xportal/xmain?xpid=INE&xpgid=ine_publicacoes&PUBLICACOESpub_boui=445098890&PUBLICACOESmodo=2
Insert cell
// europe gdp/pop NUTS 3
//https://ec.europa.eu/eurostat/databrowser/view/NAMA_10R_3GDP/default/table?lang=en&category=na10.nama10.nama_10reg.nama_10r_gdp
//https://ec.europa.eu/eurostat/databrowser/view/NAMA_10R_3POPGDP/default/map?lang=en&category=na10.nama10.nama_10reg.nama_10r_gdp
// NUTS3_pop = d3.csv("https://gist.githubusercontent.com/lnicoletti/c3bdf81d2d007d264697ec34453ea3e9/raw/7151baff60130ecc750acb6191adbda127157925/NUTS3_pop.csv", d3.autoType)
Insert cell
// NUTS3_gdp = d3.csv("https://gist.githubusercontent.com/lnicoletti/c478121e02bcd2a46ab8bae6755dcaca/raw/e97985bd8b2205762af8a6e4af9132d1f8a11ef7/NUTS3_gdp.csv", d3.autoType)
Insert cell
// NUTS3_income = NUTS3_gdp.filter(d=>d.TIME_PERIOD===2018)
// .map(d=>{return{
// province:d.geo,
// income:d.OBS_VALUE/NUTS3_pop.filter(c=>c.TIME_PERIOD===2018&&c.geo===d.geo)[0].OBS_VALUE*1000
// }})
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
Insert cell
countries_sm = d3.merge([uKUpd_sm, uSUpd_sm, itUpd_sm, fRUpd_sm, nLUpd_sm, cAUpd_sm, AUUpd_sm, dKUpd_sm, sEUpd_sm, nOUpd_sm, eSUpd_sm, pTUpd_sm])
Insert cell
Insert cell
Insert cell
t = dKUpd_sm.filter(d=>d.country==="Denmark")
Insert cell
d3.extent(t, d=>d.income)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
codesLondon = "E09000001,E09000033,E09000002,E09000003,E09000004,E09000005,E09000006,E09000007,E09000008,E09000009,E09000010,E09000012,E09000013,E09000014,E09000015,E09000016,E09000017,E09000018,E09000019,E09000022,E09000023,E09000024,E09000025,E09000026,E09000027,E09000028,E09000029,E09000030,E09000031,E09000032,E09000011,E09000020,E09000021".split(",").concat(londonLUZ)
Insert cell
londonLUZ = ["E07000095", "E07000242", "E07000096", "E07000098", "E07000102", "E07000243", "E07000240", "E07000103", "E07000241", "E07000066", "E07000068", "E07000069", "E07000070", "E07000072", "E07000073", "E07000074", "E07000075", "E06000033", "E06000034", "E07000077", "E07000107", "E07000109", "E07000110", "E06000035", "E07000115", "E07000116", "E07000111", "E07000207", "E07000208", "E07000209", "E07000210", "E07000211", "E07000212", "E07000213", "E07000214", "E07000215", "E07000217", "E06000036", "E06000039", "E06000040", ]

//https://en.wikipedia.org/wiki/Larger_urban_zone
//https://en.wikipedia.org/wiki/London_metropolitan_area#cite_note-9
Insert cell
// hexes_UK.filter(d=>d.n.toLowerCase().match("S".toLowerCase()))
Insert cell
londonCommuterBelt = ["E06000038", "E06000033", "E06000035", "E06000032", "E07000209", "E07000216", "E06000036", "E07000089", "E07000214", "E07000226", "E06000039", "E07000066", "E06000060", "E07000070", "E07000084", "E07000110", "E07000243", "E07000242", "E07000099", "E07000116", "E06000040", "E07000241", "E07000211", "E07000068", "E07000227", "E07000115", "E06000056", "E07000111"]

//https://web.archive.org/web/20150924002318/http://www.espon.eu/export/sites/default/Documents/Projects/ESPON2006Projects/StudiesScientificSupportProjects/UrbanFunctions/fr-1.4.3_April2007-final.pdf#page=119
//https://en.wikipedia.org/wiki/London_metropolitan_area#cite_note-9
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
Insert cell
d3 = require('d3', "d3-hexjson")
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