Public
Edited
Apr 30, 2023
Fork of Hello h3-js
1 fork
4 stars
Insert cell
Insert cell
h3 = require("h3-js@3.7.2/dist/h3-js.umd.js")
Insert cell
Insert cell
Insert cell
h3.UNITS
Insert cell
Insert cell
h3Address = h3.geoToH3(37.3615593, -122.0553238, zoom)
Insert cell
Insert cell
hexCenterCoordinates = h3.h3ToGeo(h3Address)
Insert cell
Insert cell
hexBoundary = h3.h3ToGeoBoundary(h3Address, true)
Insert cell
Insert cell
// Get all neighbors within 1 step of the hexagon
kRing = h3.kRing(h3Address, 1)
Insert cell
Insert cell
Insert cell
// Get the set of hexagons within a polygon
// last boolean flags are the GeoJson flag, that returns proper GeoJSON lon-lat ordered objects
hexagons = {
const hexagons = h3.polyfill(triangle.coordinates[0], zoom, true);

// Get the outline of a set of hexagons, as a GeoJSON-style MultiPolygon
const coordinates = h3.h3SetToMultiPolygon(hexagons, true);

return coordinates;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// note: This doesn't deal with holes, luckily our geometry doesnt have any.
poly = d3.merge(california.geometry.coordinates.map(d => h3.polyfill(d[0],6,true)))
Insert cell
Insert cell
coordinates = {
var multi = h3.h3SetToMultiPolygon(compacted, true);
multi.forEach(m => m.forEach((n,i) => {
m[i] = n
.reverse();
m[i].push(m[i][0]);
}));
return multi;
}
Insert cell
Insert cell
Insert cell
Insert cell
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