Published
Edited
Sep 20, 2019
1 fork
Insert cell
md`# Region rings Berlin`
Insert cell
allCities = new Set(rawPaths.features.map(p => p.properties.dloc))
Insert cell
distances = rawPaths.features.filter(p => p.properties.dloc!=='Probe').filter(p => !turf.booleanContains(prbEnvelope, turf.point(p.geometry.coordinates[1]))).map(ls => {
// go ahead, mix strings and numbers in a json field!
let coords0 = ls.geometry.coordinates[0].map(i => Number(i));
let coords1 = ls.geometry.coordinates[1].map(i => Number(i));
return { srcLoc: ls.properties.sloc, dstLoc: ls.properties.dloc, coordinates: ls.geometry.coordinates[1], dist: turf.distance(coords0, coords1) }
})
Insert cell
prbEnvelope = turf.envelope(prbGeoJson);
Insert cell
turf.inside
Insert cell
[d3.min(distances, d => d.dist), d3.max(distances, d => d.dist), d3.mean(distances, d => d.dist)]
Insert cell
map = html`<svg viewBox="0 0 ${width} ${height}" style="display: block;">
<style>
.world { stroke: #eeeeee; stroke-width: 0.5; fill-opacity: 0.5 }
.hop-loc { fill: none; stroke-width: 1.5; stroke: black; }
.probe-loc { stroke-width: 2; stroke: none; fill: white; fill-opacity: 0.8 }
.l-path { fill: none; stroke-width: 2; stroke: lightBlue; }
.kreis { fill-opacity: 0.8; }
.bunch-of-lines { stroke: black; stroke-width: 0.4; fill: none; stroke-opacity: 0.6; }
</style>
<defs>
<path id="outline" d="${path(outline)}" />
<clipPath id="clip"><use xlink:href="${new URL("#outline", location)}" /></clipPath>
</defs>
<g class="world" clip-path="url(${new URL("#clip", location)})">
<use xlink:href="${new URL("#outline", location)}" fill="#fff" />
${land.features.map(l => `<path class="kreis" d="${path(l.geometry)}" style="fill: ${popKreisColor(l.properties.pop_density)}"></path>`)}
</g>
<g class="bunch-of-lines"><path d="${path(rawPaths)}"/></g>
<use xlink:href="${new URL("#outline", location)}" fill="none" stroke="#000" />
</svg>`
Insert cell
Insert cell
height = 1200
Insert cell
popKreisColor = d3.scaleLinear()
.domain([30, 580])
.range(["#ffffff", "#cccccc"])
.interpolate(d3.interpolateLab);
Insert cell
path = d3.geoPath(projection.scale(3150).rotate([-10,-57]))
Insert cell
projection = d3.geoMercator()
Insert cell
rawPaths = fetch("https://sg-pub.ripe.net/emile/ixp-country-jedi/specials/2019-08-22-Berlin/geopath/geopath.v4.json").then(d => d.json())
Insert cell
probes = fetch("https://sg-pub.ripe.net/emile/ixp-country-jedi/specials/2019-08-22-Berlin/probeset.json").then(d => d.json())
Insert cell
prbGeoJson = Object.assign({
type: 'FeatureCollection',
features: probes.map(p => ({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [p.lon, p.lat]
}
})
)
});
Insert cell
world = fetch("https://www-static.ripe.net/static/rnd-ui/openipmap/production/maps/country_deu_adm2.topo.json").then(r => r.json())
Insert cell
land = topojson.feature(world, world.objects["country_deu_adm2"])
Insert cell
outline = ({type: "Sphere"})
Insert cell
turf = require("https://npmcdn.com/@turf/turf@5.1.6/turf.js")
Insert cell
d3 = require("d3@5")
Insert cell
topojson = import("topojson-client@3")
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