Skip to main content
Version: 4.x

Indexing functions

These functions are used for finding the H3 cell index containing coordinates, and for finding the center and boundary of H3 cells.

latLngToCell

Indexes the location at the specified resolution, providing the index of the cell containing the location. This buckets the geographic point into the H3 grid. For more information, see the algorithm description.

H3Error latLngToCell(const LatLng *g, int res, H3Index *out);

Returns 0 (E_SUCCESS) on success.

cellToLatLng

Finds the center of the cell in grid space. See the algorithm description for more information.

The center will drift versus the centroid of the cell on Earth due to distortion from the gnomonic projection within the icosahedron face it resides on and its distance from the center of the icosahedron face.

H3Error cellToLatLng(H3Index cell, LatLng *g);

Returns 0 (E_SUCCESS) on success.

cellToBoundary

Finds the boundary of the cell. For more information, see the algorithm description.

H3Error cellToBoundary(H3Index cell, CellBoundary *bndry);

Returns 0 (E_SUCCESS) on success.