Published
Edited
Sep 20, 2022
2 stars
Insert cell
Insert cell
Insert cell
config = ({
lat: 60,
lng: 60,
zoom: 0,
});
Insert cell
{
renderMapLayer({map, id: 'poly', data: polarPolygon, type: 'line', paint: {'line-color': 'blue'}});
renderH3IndexesToMap(map, 'hexes', badHexagons);
renderH3IndexesToMap(map, 'hexes', goodHexagons, {'fill-color': 'green'});
return md`*{map rendering logic}*`
}
Insert cell
// Use an H3 base cell as an example polygon
polarPolygon = ({
type: 'Feature',
geometry: {
type: 'Polygon',
coordinates: [h3.h3ToGeoBoundary('8100fffffffffff', true)]
}
})
Insert cell
goodHexagons = {
const coords = polarPolygon.geometry.coordinates[0];
const hexagons = [];
for (let i = 0; i < coords.length - 1; i++) {
const triangle = [coords[i], coords[i + 1], [0, 89.999]];
hexagons.push(...h3.polyfill(triangle, 2, {geojson: true}));
}
return hexagons;
}
Insert cell
badHexagons = {
// This doesn't work with a polar polygon
return h3.polyfill(polarPolygon.geometry.coordinates, 2, {geojson: true});
}
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