Expand description
The h3o
library implements the H3 geospatial indexing system.
H3 is a geospatial indexing system using a hexagonal grid that can be (approximately) subdivided into finer and finer hexagonal grids, combining the benefits of a hexagonal grid with S2’s hierarchical subdivisions.
§Crate features
-
std - When enabled, this will cause
h3o
to use the standard library. In terms of APIs,std
causes error types to implement thestd::error::Error
trait. Enablingstd
will also result in performance optimizations. -
geo - When enabled, you’ll be able to convert lists of H3 cell indexes from and into geometric shapes. Also enables the
GeoJSON
support. Requiresstd
. -
serde - When enabled, H3 index types (cell, vertex and edge) derive serde traits.
§H3 to H3O mapping
For people used to the H3 API, here is the mapping to H3O.
§Indexing functions
H3 | H3O |
---|---|
latLngToCell | LatLng::to_cell |
cellToLatLng | LatLng::from |
cellToBoundary | CellIndex::boundary |
§Index inspection functions
H3 | H3O |
---|---|
getResolution | CellIndex::resolution |
getBaseCellNumber | CellIndex::base_cell |
stringToH3 | str::parse |
h3ToString | ToString::to_string |
isValidCell | CellIndex::try_from |
isResClassIII | Resolution::is_class3 |
isPentagon | CellIndex::is_pentagon |
getIcosahedronFaces | CellIndex::icosahedron_faces |
maxFaceCount | CellIndex::max_face_count |
§Grid traversal functions
H3 | H3O |
---|---|
gridDisk | CellIndex::grid_disk |
maxGridDiskSize | max_grid_disk_size |
gridDiskDistances | CellIndex::grid_disk_distances |
gridDiskUnsafe | CellIndex::grid_disk_fast |
gridDiskDistancesUnsafe | CellIndex::grid_disk_distances_fast |
gridDiskDistancesSafe | CellIndex::grid_disk_distances_safe |
gridDisksUnsafe | CellIndex::grid_disks_fast |
gridRingUnsafe | CellIndex::grid_ring_fast |
gridPathCells | CellIndex::grid_path_cells |
gridPathCellsSize | CellIndex::grid_path_cells_size |
gridDistance | CellIndex::grid_distance |
cellToLocalIj | CellIndex::to_local_ij |
localIjToCell | CellIndex::try_from |
§Hierarchical grid functions
H3 | H3O |
---|---|
cellToParent | CellIndex::parent |
cellToChildren | CellIndex::children |
cellToChildrenSize | CellIndex::children_count |
cellToCenterChild | CellIndex::center_child |
cellToChildPos | CellIndex::child_position |
childPosToCell | CellIndex::child_at |
compactCells | CellIndex::compact |
uncompactCells | CellIndex::uncompact |
uncompactCellsSize | CellIndex::uncompact_size |
§Region functions
H3 | H3O |
---|---|
polygonToCells | geom::ToCells::to_cells |
maxPolygonToCellsSize | geom::ToCells::max_cells_count |
h3SetToLinkedGeo | geom::ToGeo::to_geom |
destroyLinkedPolygon | N/A |
§Directed edge functions
H3 | H3O |
---|---|
areNeighborCells | CellIndex::is_neighbor_with |
cellsToDirectedEdge | CellIndex::edge |
isValidDirectedEdge | DirectedEdgeIndex::try_from |
getDirectedEdgeOrigin | DirectedEdgeIndex::origin |
getDirectedEdgeDestination | DirectedEdgeIndex::destination |
directedEdgeToCells | DirectedEdgeIndex::cells |
originToDirectedEdges | CellIndex::edges |
directedEdgeToBoundary | DirectedEdgeIndex::boundary |
§Vertex functions
H3 | H3O |
---|---|
cellToVertex | CellIndex::vertex |
cellToVertexes | CellIndex::vertexes |
vertexToLatLng | LatLng::from |
isValidVertex | VertexIndex::try_from |
§Miscellaneous H3 functions
H3 | H3O |
---|---|
degsToRads | f64::to_radians |
radsToDegs | f64::to_degrees |
getHexagonAreaAvgKm2 | Resolution::area_km2 |
getHexagonAreaAvgM2 | Resolution::area_m2 |
cellAreaKm2 | CellIndex::area_km2 |
cellAreaM2 | CellIndex::area_m2 |
cellAreaRads2 | CellIndex::area_rads2 |
getHexagonEdgeLengthAvgKm | Resolution::edge_length_km |
getHexagonEdgeLengthAvgM | Resolution::edge_length_m |
edgeLengthKm | DirectedEdgeIndex::length_km |
edgeLengthM | DirectedEdgeIndex::length_m |
edgeLengthRads | DirectedEdgeIndex::length_rads |
getNumCells | Resolution::cell_count |
getRes0Cells | CellIndex::base_cells |
res0CellCount | BaseCell::count |
getPentagons | Resolution::pentagons |
pentagonCount | Resolution::pentagon_count |
greatCircleDistanceKm | LatLng::distance_km |
greatCircleDistanceM | LatLng::distance_m |
greatCircleDistanceRads | LatLng::distance_rads |
Modules§
- H3O error types.
- Bridge between H3 entities and geometrical shapes.
Structs§
- One of the 122 base cells.
- Boundary in latitude/longitude.
- Represents a cell (hexagon or pentagon) in the H3 grid system at a particular resolution.
- IJ hexagon coordinates.
- Represents a single directed edge between two cells (an “origin” cell and a neighboring “destination” cell).
- Edge of an H3 cell.
- An icosahedron face.
- A set of icosahedron faces.
- Latitude/longitude.
IJ
coordinates anchored by an origin.- Vertex of an H3 cell.
- Represents a single topological vertex in H3 grid system, shared by three cells.
Enums§
- A direction within an hexagonal grid.
- H3 index modes.
- Cell resolution, from 0 to 15.
Constants§
- Earth radius in kilometers using WGS84 authalic radius.
Functions§
- Maximum number of indices produced by the grid disk algorithm with the given
k
.