Published
Edited
Jun 22, 2022
1 star
Insert cell
Insert cell
Insert cell
array = []
Insert cell
Insert cell
// a square size
a = 3.2
Insert cell
{
const svg = d3.create("svg").attr("width", width).attr("height", height);
svg
.selectAll("rect")
.data(coords)
.join("rect")
.attr("width", a)
.attr("height", a)
.style("fill", "rgba(37,124,163, 0.99)")
.attr("x", (d) => d.lon)
.attr("y", (d) => d.lat);

return svg.node();
}
Insert cell
## Regular Grid
Insert cell
regularGrid
Insert cell
array

Insert cell
Insert cell
Insert cell
regularGrid = []
Insert cell
Insert cell
coords
Insert cell
Insert cell
coords = []
Insert cell
lat2pixel = function (y) {
return height - canvas_resolution * Math.round((y + lat_offset) / resolution);
}
Insert cell
lon2pixel = function (x) {
return canvas_resolution * Math.round((x + lon_offset) / resolution);
}
Insert cell
lat_offset = 2793275
Insert cell
lon_offset = 2795725
Insert cell
canvas_resolution = 5
Insert cell
resolution = 45000
Insert cell
Insert cell
height = width
Insert cell
width = 700
Insert cell
grid
Insert cell
grid = FileAttachment("antarctic_ice_vel_notnull_45.csv").csv()
Insert cell
Insert cell
Insert cell
gsap = gs.gsap
Insert cell
Insert cell
d3 = require("d3@5")
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