Public
Edited
May 25, 2022
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
land = topojson.merge(countries_simplified, countries_simplified.objects.countries_110m.geometries)
Insert cell
Insert cell
Insert cell
ocean = {
const c = land.coordinates.slice().sort(([a], [b]) => b.length - a.length);
return {
type: "MultiPolygon",
coordinates: [
c.map(([outerRing]) => outerRing.slice().reverse()),
c.flatMap(([, ...holes]) => holes.map((r) => r.slice().reverse()))
]
};
}
Insert cell
Insert cell
Insert cell
oceanRewind = turf.rewind(land, {reverse: false}) // 👎 Ne fonctionne pas
Insert cell
Insert cell
Insert cell
sphere = ({
"type": "Polygon",
"coordinates": [ [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]] ]
})
Insert cell
// /!\ return geojson RFC 7946 compatible
oceanDiff = ({
"type": "MultiPolygon",
"coordinates": clip.difference(sphere.coordinates, land.coordinates)
})
Insert cell
Insert cell
Insert cell
oceanDiffRewind = turf.rewind(oceanDiff, {reverse: true})
Insert cell
Insert cell
Insert cell
Insert cell
projection = d3.geoEqualEarth().rotate([-150,0])
Insert cell
path = d3.geoPath(projection)
Insert cell
Insert cell
height = {
const [[x0, y0], [x1, y1]] = d3.geoPath(projection.fitWidth(width, outline)).bounds(outline)
const dy = Math.ceil(y1 - y0)
return dy;
}
Insert cell
outline = ({type: "Sphere"})
Insert cell
Insert cell
Insert cell
turf = require("@turf/turf")
Insert cell
clip = require("polygon-clipping@0.15.3")
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