Published unlisted
Edited
Jun 10, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function projectionTop(proj) {
return proj.preclip(
d3.geoClipPolygon({
type: "Polygon",
coordinates: [
proj
.preclip()
.polygon()
.coordinates[0].map(d => [d[0], Math.max(-57, d[1])])
]
})
);
}
Insert cell
function antarcticaRaw(proj) {
const octantProjectionW = proj
.rotate([0, 0])
.center([45, -89.9999])
.scale(1);
//octantProjectionW.center([0, -89.9999]).translate([0, 0]);
const octantProjection = function(lambda, phi) {
return octantProjectionW([lambda * degrees, phi * degrees]);
};
const zero = octantProjectionW([45, -90]);
return function(lambda, phi) {
lambda = (500 * tau + lambda) % tau;
const octant = Math.floor(lambda / halfPi),
a = octant * halfPi;
lambda -= octant * halfPi;

const raw = octantProjectionW([lambda * degrees, phi * degrees]);
raw[0] -= zero[0];
raw[1] -= zero[1];
return [
-(raw[0] * cos(a) - raw[1] * sin(a)),
raw[0] * sin(a) + raw[1] * cos(a)
];
};
}
Insert cell
function projectionBottom(proj) {
const low = -73,
high = -65;

function interpolateParallel(from, to, latitude) {
return d3.range(from, to, 1).map(d => [d, latitude]);
}

const polygon = {
type: "Polygon",
coordinates: [
[
...interpolateParallel(90.000001, 179.999999, high),
[180, low],
...interpolateParallel(-179.999999, -90.000001, high),
[-90, low],
...interpolateParallel(-89.999999, -0.000001, high),
[0, low],
...interpolateParallel(0.000001, 89.999999, high),
[90, low],
[90.000001, high]
]
]
};

const projection = d3
.geoProjection(antarcticaRaw(proj))
.preclip(d3.geoClipPolygon(polygon));

return projection;
}
Insert cell
octantProjection = d3.geoCahillKeyesRaw(1)
Insert cell
octantProjection(0, -halfPi)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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