Published
Edited
Oct 7, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
planSCountries = ["Finland", "Norway", "Ireland", "South Africa", "Austria", "France", "Italy", "Luxembourg", "Poland", "Slovenia", "Sweden", "Canada", "Netherlands", "Switzerland", "Jordan", "Portugal", "Belgium", "Bulgaria", "Croatia", "Czechia", "Denmark", "Germany", "Hungary", "Iceland", "Latvia", "Lithuania", "Romania", "Serbia", "Slovakia", "Spain", "Ukraine", "Switzerland", "Australia"]

Insert cell
Insert cell
gwp4 = FileAttachment("pophex.topjson").json(); //https://raw.githubusercontent.com/neocarto/resources/master/datasets/ciesin/pophex.topjson
Insert cell
landJson = FileAttachment("land.topojson").json(); ///https://raw.githubusercontent.com/neocarto/resources/master/datasets/ciesin/land.topojson
Insert cell
land = topojson.feature(landJson, landJson.objects.land)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
countriesJson = FileAttachment("countries-110m.json").json();
Insert cell
countries = topojson.feature(countriesJson, countriesJson.objects.countries)
Insert cell
inverseFilteredCountries = topojson.merge(simplifiedCountries, simplifiedCountries.objects.countries.geometries.filter(function(d) { return !(planSCountries.includes(d.properties.name)); }))
Insert cell
// Check whether the country is in our list of plan S countries, thus data shouldn't be shown
filteredCountries = topojson.merge(simplifiedCountries, simplifiedCountries.objects.countries.geometries.filter(function(d) { return (planSCountries.includes(d.properties.name)); }))
Insert cell
simplify = (geo, val) => {
let simplified = topojson.presimplify(geo);
let min_weight = topojson.quantile(simplified, val);
//Every arc coordinate whose z-value is lower than min_weight is removed
return topojson.simplify(simplified, min_weight);
}
Insert cell
simplifiedCountries = countriesJson// simplify(countriesJson, .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
d3 = require("d3@6", "d3-geo-projection@2")
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