Skip to main content
Version: 4.x (release candidate)

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.

exactEdgeLengthKm

H3Error exactEdgeLengthKm(H3Index edge, double *length);

Exact edge length of specific unidirectional edge in kilometers.

exactEdgeLengthM

H3Error exactEdgeLengthM(H3Index edge, double *length);

Exact edge length of specific unidirectional edge in meters.

exactEdgeLengthRads

H3Error exactEdgeLengthRads(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 indexes. out must be an array of at least size res0CellCount().

res0CellCount

int res0CellCount();

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();

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.