Public
Edited
Mar 4
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3.geoArea(feature(sliver))
Insert cell
d3.polygonArea(sliver[0])
Insert cell
Insert cell
Insert cell
transformations = [
["(no transform)", (d) => d],
["placemark.rewind", (shape) => placemark.rewindFeature(shape, "RFC7946")],
["placemark.rewind (D3)", (shape) => placemark.rewindFeature(shape, "d3")],
["turf", (shape) => turf.rewind(shape)],
["turf (reverse)", (shape) => turf.rewind(shape, { reverse: true })],
["geotoolbox", (shape) => geotoolbox.rewind(shape, { mutate: false })],
["@fil/rewind", rewind]
]
Insert cell
transformed = {
return Array.from(transformations, ([name, rewind]) => [
name,
[
rewind(countries_geo_10m),
rewind(feature(sliver)),
rewind(feature(sliver2)),
rewind(feature(pole))
]
]);
}
Insert cell
feature = (d) =>
Array.isArray(d)
? {
type: "FeatureCollection",
features: [
{ type: "Feature", geometry: { type: "Polygon", coordinates: d } }
]
}
: d
Insert cell
draw = (shape, title) =>
Plot.plot({
title,
projection: "equal-earth",
marks: [
Plot.geo(shape, { fill: "#ccc", stroke: "currentColor" }),
Plot.graticule(),
Plot.sphere()
]
})
Insert cell
pole = [
[
[0, 80],
[120, 80],
[-120, 80],
[0, 80]
]
]
Insert cell
sliver = [
[
[20, 15],
[15, 15.05],
[10, 15],
[20, 15]
]
]
Insert cell
sliver2 = [
[
[0, 0],
[5.2, 5],
[10, 10],
[0, 0]
]
]
Insert cell
// import { countries_geo_10m } from "@plmrry/winding-order-woes"
countries_geo_10m = FileAttachment("countries_geo_10m.json").json()
Insert cell
import { geo as geotoolbox } from "@neocartocnrs/rewind"
Insert cell
turf = require("@turf/turf@7")
Insert cell
import {rewind} from "@fil/rewind"
Insert cell
placemark = import("https://esm.sh/@placemarkio/geojson-rewind")
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