Skip to main content
Version: 4.x

Miscellaneous H3 functions

These functions include descriptions of the H3 grid system.

degsToRads

double degsToRads(double degrees);

Converts degrees to radians.

radsToDegs

double radsToDegs(double radians);

Converts radians to degrees.

getHexagonAreaAvgKm2

H3Error getHexagonAreaAvgKm2(int res, double *out);

Average hexagon area in square kilometers at the given resolution. Excludes pentagons.

getHexagonAreaAvgM2

H3Error getHexagonAreaAvgM2(int res, double *out);

Average hexagon area in square meters at the given resolution. Excludes pentagons.

cellAreaRads2

H3Error cellAreaRads2(H3Index h, double *out);

Exact area of specific cell in square radians.

cellAreaKm2

H3Error cellAreaKm2(H3Index h, double *out);

Exact area of specific cell in square kilometers.

cellAreaM2

H3Error cellAreaM2(H3Index h, double *out);

Exact area of specific cell in square meters.

getHexagonEdgeLengthAvgKm

H3Error getHexagonEdgeLengthAvgKm(int res, double *out);

Average hexagon edge length in kilometers at the given resolution. Excludes pentagons.

getHexagonEdgeLengthAvgM

H3Error getHexagonEdgeLengthAvgM(int res, double *out);

Average hexagon edge length in meters at the given resolution. Excludes pentagons.

edgeLengthKm

H3Error edgeLengthKm(H3Index edge, double *length);

Exact edge length of specific unidirectional edge in kilometers.

edgeLengthM

H3Error edgeLengthM(H3Index edge, double *length);

Exact edge length of specific unidirectional edge in meters.

edgeLengthRads

H3Error edgeLengthRads(H3Index edge, double *length);

Exact edge length of specific unidirectional edge in radians.

getNumCells

H3Error getNumCells(int res, int64_t *out);

Number of unique H3 indexes at the given resolution.

getRes0Cells

H3Error getRes0Cells(H3Index *out);

All the resolution 0 H3 cell indexes. These are the coarsest cells that can be represented in the H3 system and are the parents of all other cell indexes in the H3 grid system. The returned indexes correspond with the 122 base cells.

out must be an array of at least size res0CellCount().

res0CellCount

int res0CellCount(void);

Number of resolution 0 H3 indexes, which is defined as 122.

getPentagons

H3Error getPentagons(int res, H3Index *out);

All the pentagon H3 indexes at the specified resolution. out must be an array of at least size pentagonIndexCount().

Returns 0 (E_SUCCESS) on success.

pentagonCount

int pentagonCount(void);

Number of pentagon H3 indexes per resolution. This is always 12, but provided as a convenience.

greatCircleDistanceKm

double greatCircleDistanceKm(const LatLng *a, const LatLng *b);

Gives the "great circle" or "haversine" distance between pairs of LatLng points (lat/lng pairs) in kilometers.

greatCircleDistanceM

double greatCircleDistanceM(const LatLng *a, const LatLng *b);

Gives the "great circle" or "haversine" distance between pairs of LatLng points (lat/lng pairs) in meters.

greatCircleDistanceRads

double greatCircleDistanceRads(const LatLng *a, const LatLng *b);

Gives the "great circle" or "haversine" distance between pairs of LatLng points (lat/lng pairs) in radians.