0

I'm trying to create a Grid Layer of Either Rectangles or Hexagons in React Map GL(Map Box) and Deck GL, that cover an entire country.

This is what I'm trying to achieve: http://webcoveragemap.rootmetrics.com/en-US

These are the Solutions I've found:

  1. https://deck.gl/#/documentation/deckgl-api-reference/layers/s2-layer
  2. https://deck.gl/#/documentation/deckgl-api-reference/layers/h3-cluster-layer

The problem I'm facing with is that s2-layer uses S2 Cell token (Which I can't seem to understand how to calculate and similarly h3-cluster-layer uses H3 and for that too I can't find any code samples for React. So can anybody explain me either how to use H3, S2 and calculate 50sq km boxes that can be viewed on React Map Gl with Deck GL (if needed). Or suggest another Solution?

Jawad Farooqi
  • 335
  • 3
  • 14

1 Answers1

1

Turns out there's java script version of H3-Core Library (A hexagon-based geographic grid system). https://www.npmjs.com/package/h3-js

All it require's to convert a lat/lng point to a hexagon index at some resolution is following code:

const h3Index = h3.geoToH3(37.3615593, -122.0553238, 7);
// -> '87283472bffffff'
Jawad Farooqi
  • 335
  • 3
  • 14