Indexing functions
These function are used for finding the H3 index containing coordinates, and for finding the center and boundary of H3 indexes.
geoToH3
- C
- Python
- Java
- JavaScript (Live)
H3Index geoToH3(const GeoCoord *g, int res);
h3.geo_to_h3(lat, lng, resolution)
long geoToH3(double lat, double lng, int res);
String geoToH3Address(double lat, double lng, int res);
h3.geoToH3(lat, lng, res)
Live Editor
Result
Loading...
Indexes the location at the specified resolution, returning the index of the cell containing the location. This buckets the geographic point into the H3 grid. See the algorithm description for more information.
Returns 0 on error.
h3ToGeo
- C
- Python
- Java
- JavaScript (Live)
void h3ToGeo(H3Index h3, GeoCoord *g);
h3.h3_to_geo(h)
GeoCoord h3ToGeo(long h3);
GeoCoord h3ToGeo(String h3Address);
h3.h3ToGeo(h3Index)
Live Editor
Result
Loading...
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.
h3ToGeoBoundary
- C
- Python
- Java
- JavaScript (Live)
void h3ToGeoBoundary(H3Index h3, GeoBoundary *gp);
h3.h3_to_geo_boundary(h, geo_json=False)
List<GeoCoord> h3ToGeoBoundary(long h3);
List<GeoCoord> h3ToGeoBoundary(String h3Address);
h3.h3ToGeoBoundary(h3Index, [formatAsGeoJson])
Live Editor
Result
Loading...
Finds the boundary of the cell. See the algorithm description for more information.