Public
Edited
Nov 15, 2022
1 fork
Importers
6 stars
Insert cell
Insert cell
Insert cell
raw = {
const rawLee = d3
.geoTetrahedralLee()
.rotate(rotate)
.fitExtent([[-4, -1.5 / sqrt3_4], [4, 1.5 / sqrt3_4]], {
type: "Sphere"
});

const forward = (l, p) => {
let [x, y] = rawLee([l * degrees, p * degrees]);
y = -y;

if (x < -2.1 || y < -2.73) {
x = -x - 4;
y = -y;
}

if (x < -4) {
x = -x - 8;
y = 6.93 - y; // 6.93 is a visual approximation—haven't figured out the exact value yet (please help!)
}

return [x, y];
};

forward.invert = (x, y) => {
y = -y;
const a =
rawLee.invert([x, y]) ||
rawLee.invert([-x - 4, -y]) ||
rawLee.invert([-x - 8, 6.93 - y]) ||
rawLee.invert([-(-x - 8) - 4, 6.93 + y]);

if (a) return [a[0] * radians, a[1] * radians];
};

return forward;
}
Insert cell
Insert cell
Insert cell
land1 = d3.json(
"https://unpkg.com/visionscarto-world-atlas@0.0.4/world/110m_land.geojson"
)
Insert cell
land = {
// comment out if you need a simplified version.
return land1;

const topojson =
await require("topojson-client", "topojson-server", "topojson-simplify");
let t = topojson.topology({ land: land1 });
t = topojson.presimplify(t, topojson.sphericalTriangleArea);
t = topojson.simplify(t, 0.00001);
return topojson.feature(t, t.objects.land);
}
Insert cell
projection = (() =>
d3.geoProjection(raw).preclip(d3.geoClipPolygon(clipPolygon())))().angle(
57 - 180
)
Insert cell
Insert cell
clipPolygon = () => ({
type: "Polygon",
coordinates: [
[
[-20, 0],
[-27, 14],
[-27, 18],
[-20, 37],
[-30, 37],
[-35, -40],
[-30, -70],
[40, -50],
[70, -40],
[120, -60],
[150, -60],
[180, -60],
[-150, -50],
[-110, -40],
[-110, -30],
[-170, 10],
[160, 40],
[150, 40],
[150, 30],
[-170, 0],
[-150, -10],
[-140, -30],
[-170, -50],
[120, -50],
[90, -30],
[60, -25],
[30, -38],
[10, -38],
[-20, 0]
].map(d => [d[0] - .01, d[1] - .01])
]
})
Insert cell
import {
d3,
drag,
vertices,
sqrt3_4,
degrees,
radians,
rotate
} from "@fil/markley"
Insert cell
height = (width / 2.22) | 0
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