Public
Edited
Oct 6, 2024
Paused
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// The data comes in a ZIP archive.
archive = FileAttachment("PaleoDEMS_long_lat_elev_csv_v2.zip")
.arrayBuffer()
.then(buffer => jszip.loadAsync(buffer))

Insert cell
// Extraction of the file corresponding to the selected geologic time period.
filenames = Object.values(archive.files)
.filter(f => f.dir === false)
.map(f => {
const age = f.name.replace(/.*_/, "").replace(".csv", "");
return { name: age, value: f.name };
})
Insert cell
map = archive.file(fileName).async("text")
Insert cell
// The formatting of the files is not completely consistent.
parsedData = d3
// Standardize carriage returns
.csvParse(map.replace(/\r/g, "\n"))
// Standardize field names
.map(p => {
let lon = p["# lon"] !== undefined ? p["# lon"] : p.longitude;
let lat = p.lat !== undefined ? p.lat : p.latitude;
let elev = p.elev !== undefined ? p.elev : p.elevation;
return { lon, lat, elev };
})
Insert cell
// Standardize array sizes: some extend to [+180, -90], others stop at [+179, -89]
// (data is ordered in rows from top left to bottom right)
vals = parsedData.filter(d => d.lon < 180 && d.lat > -90).map(d => d.elev)
Insert cell
// Construct the DEM object
dem = Object({
width: 360,
height: 180,
data: vals
})
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
chroma = require("chroma-js@2.1.0")
Insert cell
jszip = require("jszip@3.1.5/dist/jszip.min.js")
Insert cell
d3 = require("d3@5", "d3-geo", "d3-format", "d3-contour")
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