Public
Edited
May 27, 2023
1 fork
14 stars
Insert cell
Insert cell
Insert cell
map = Plot.plot({
projection: { type: "equal-earth", rotate: [-10, 0] },
width: 928,
color: {
type: "log",
domain: [0.25, 5, 21, 100],
range: ["#d3e7fa", "#5784c5", "#fc004b", "#ffec44"],
clamp: true
},
marks: [
Plot.raster(ev, {
pixelSize: 0.8,
x: "gap_start_lon",
y: "gap_start_lat",
fill: 1,
interpolate: interpolateSum,
clip: "sphere"
}),
Plot.geo(land, { fill: "white" }),
Plot.tip(
ev,
Plot.pointer(
Plot.hexbin(
{ fill: "count", x: "median", y: "median" },
{ x: "gap_start_lon", y: "gap_start_lat", binWidth }
)
)
)
]
})
Insert cell
Insert cell
function interpolateSum(index, width, height, X, Y, V) {
const U = new Float64Array(width * height);
for (const i of index) {
const x = Math.floor(X[i]);
const y = Math.floor(Y[i]);
if (x >= 0 && y >= 0 && x < width && y < height) U[x + width * y] += V[i];
}
return U;
}
Insert cell
Insert cell
Insert cell
binWidth = Math.sqrt(2 / Math.sqrt(3)) * 0.8
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function interpolateSumLinear(index, width, height, X, Y, V) {
const U = new Float64Array(width * height);
for (const i of index) {
const x = Math.floor(X[i] - 0.5);
const y = Math.floor(Y[i] - 0.5);
const dx = X[i] - 0.5 - x;
const dy = Y[i] - 0.5 - y;
for (const [a, b, w] of [
[x, y, (1 - dx) * (1 - dy)],
[x + 1, y, dx * (1 - dy)],
[x, y + 1, (1 - dx) * dy],
[x + 1, y + 1, dx * dy]
]) {
if (a >= 0 && b >= 0 && a < width && b < height)
U[a + width * b] += w * V[i];
}
}
return U;
}
Insert cell
Insert cell
// Copied from https://observablehq.com/@climatelab/map-where-do-fishing-boats-disable-their-transponders
ev = FileAttachment("ais_disabling_events.csv").csv()
Insert cell
import { land } from "@visionscarto/geo"
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