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

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