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

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