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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more