Public
Edited
Nov 21, 2024
Insert cell
Insert cell
Insert cell
randomPoints = {
const numPoints = 1000000; // Number of random points to generate
const randomPoints = [];

for (let i = 0; i < numPoints; i++) {
const lng = -180 + Math.random() * 360; // Longitude between -180 and 180
const lat = -85 + Math.random() * 170; // Latitude between -85 and 85

const randomPoint = {
h3Index: h3.latLngToCell(lat, lng, 15) // Calculate the H3 index at resolution 15
};

randomPoints.push(randomPoint);
}

return randomPoints;
}
Insert cell
import {DuckDBClient} from "@jcolot/duckdb-in-webassembly-with-loadable-extensions"
Insert cell
client = {
const c = await DuckDBClient.of({ randomPoints });
await c.query(`INSTALL h3 FROM community;`);
await c.query(`LOAD h3;`);
return c;
}
Insert cell
Select a data source…
Type SQL, then Shift-Enter. Ctrl-space for more options.

Insert cell
perf = {
const start = performance.now();
await client.query(
`select count(*) ,h3_cell_to_parent(CONCAT('0x', h3Index)::UBIGINT, 14) from randomPoints group by h3_cell_to_parent(CONCAT('0x', h3Index)::UBIGINT, 14)`
);
const end = performance.now();
return end - start;
}
Insert cell
h3 = require("h3-js@4.1.0")
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