Public
Edited
Jun 3, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
// Slightly adjusted rough coordinates from https://www.reddit.com/r/MapPorn/comments/xn7dvj/without_touching_a_single_piece_of_land_its/
// I eyeballed the coordinate under South America...sorry
IndiaToUSA = ({
type: "LineString",
coordinates: [
[-162.64094, 55.11279],
[-75.2667, -55.983],
[70.33447, 20.7972]
]
})
Insert cell
world = FileAttachment("land-110m.json").json()
Insert cell
land = topojson.feature(world, world.objects.land)
Insert cell
function interpolateProjection(raw0, raw1) {
const mutate = d3.geoProjectionMutator((t) => (x, y) => {
const [x0, y0] = raw0(x, y),
[x1, y1] = raw1(x, y);
return [x0 + t * (x1 - x0), y0 + t * (y1 - y0)];
});
let t = 0;
return Object.assign(mutate(t), {
alpha(_) {
return arguments.length ? mutate((t = +_)) : t;
}
});
}
Insert cell
projection = interpolateProjection(d3.geoOrthographicRaw, d3.geoMercatorRaw) // change from equirectangular to mercator
.scale(scale(0))
.translate([width / 2, height / 2])
.rotate(rotate(0))
.precision(0.1)
Insert cell
rotate = d3.interpolate([10, 100], [0, 0]) // 10 and 20 before, 10 and 100 works pretty well
Insert cell
scale = d3.interpolate(width / 4, (width - 2) / (2 * Math.PI))
Insert cell
height = width / 1.8
Insert cell
equator = ({type: "LineString", coordinates: [[-180, 0], [-90, 0], [0, 0], [90, 0], [180, 0]]})
Insert cell
sphere = ({type: "Sphere"})
Insert cell
graticule = d3.geoGraticule10()
Insert cell
d3 = require("d3-geo@2", "d3-interpolate@2", "d3-ease@2")
Insert cell
Insert cell
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