Public
Edited
Oct 6, 2024
Paused
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
initialProjection = d3.geoIdentity().translate([rawData.gridWidth / 2, rawData.gridHeight / 2]);
// ↳ Note that this rectangular grid could also be treated as an equirectangular projection.
// initialProjection = d3.geoEquirectangular().translate([rawData.gridWidth / 2, rawData.gridHeight / 2]).scale(57.35).reflectY(true);
Insert cell
Insert cell
Insert cell
contours = thresholds =>
d3.contours()
.size([rawData.gridWidth, rawData.gridHeight])
.thresholds(thresholds)(rawData.data);
Insert cell
function projectContour(contour) {
return {
type: contour.type,
value: contour.value,
coordinates: contour.coordinates.map(polygon =>
polygon.map(line =>
line.map(point => { return initialProjection.invert(point); })
)
)
};
}
Insert cell
projectedContours = thresholds => contours(thresholds).map(projectContour);
Insert cell
Insert cell
projectedContours([0])
Insert cell
Insert cell
projections = [
{name: "Aitoff", value: d3.geoAitoff().scale(140)},
{name: "August", value: d3.geoAugust()},
{name: "Bertin’s 1953", value: d3.geoBertin1953()},
{name: "Ginzburg V", value: d3.geoGinzburg5()},
{name: "Equirectangular", value: d3.geoEquirectangular().translate([width/2,height/2-100]).scale(150)},
{name: "Mercator", value: d3.geoMercator().translate([width/2,height/2-30]).scale(153.5)},
{name: "Miller", value: d3.geoMiller().translate([width/2,height/2-10]).scale(153.5)},
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fileMap = [
{year: "1900", file: FileAttachment("IGRF-13_declination_1900.csv") },
{year: "2020", file: FileAttachment("IGRF-13_declination_2020.csv") },
{year: "2025", file: FileAttachment("IGRF-13_declination_2025.csv") },
]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
topojson = require("topojson-client@3")
Insert cell
d3 = require("d3@5", "d3-geo-projection@3")
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