Indexing functions
These functions are used for finding the H3 cell index containing coordinates, and for finding the center and boundary of H3 indexes.
latLngToCell
- C
- Python
- Java
- JavaScript (Live)
H3Error latLngToCell(const LatLng *g, int res, H3Index *out);
h3.latlng_to_cell(lat, lng, resolution)
long latLngToCell(double lat, double lng, int res);
String latLngToCellAddress(double lat, double lng, int res);
h3.latLngToCell(lat, lng, res)
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 (E_SUCCESS
) on success.
cellToLatLng
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToLatLng(H3Index cell, LatLng *g);
h3.cell_to_latlng(cell)
LatLng cellToLatLng(long cell);
LatLng cellToLatLng(String cellAddress);
h3.cellToLatLng(cell)
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.
Returns 0 (E_SUCCESS
) on success.
cellToBoundary
- C
- Python
- Java
- JavaScript (Live)
H3Error cellToBoundary(H3Index cell, CellBoundary *bndry);
h3.cell_to_boundary(cell, geo_json=False)
List<LatLng> cellToBoundary(long cell);
List<LatLng> cellToBoundary(String cellAddress);
h3.cellToBoundary(cell, [formatAsGeoJson])
Finds the boundary of the cell. See the algorithm description for more information.
Returns 0 (E_SUCCESS
) on success.