Search Shortcut cmd + k | ctrl + k
h3

Hierarchical hexagonal indexing for geospatial data

Installing and Loading

INSTALL h3 FROM community;
LOAD h3;

Example

SELECT h3_latlng_to_cell(37.7887987, -122.3931578, 9);

About h3

The H3 extension adds support for the H3 hierarchical hexagonal grid system.

Added Functions

function_name function_type description comment example
h3_latlng_to_cell scalar Convert latitude/longitude coordinate to cell ID    
h3_latlng_to_cell_string scalar Convert latitude/longitude coordinate to cell ID (returns VARCHAR)    
h3_cell_to_lat scalar Convert cell ID to latitude    
h3_cell_to_lng scalar Convert cell ID to longitude    
h3_cell_to_latlng scalar Convert cell ID to latitude/longitude    
h3_cell_to_boundary_wkt scalar Convert cell ID to cell boundary    
h3_get_resolution scalar Get resolution number of cell ID    
h3_get_base_cell_number scalar Get base cell number of cell ID    
h3_string_to_h3 scalar Convert VARCHAR cell ID to UBIGINT    
h3_h3_to_string scalar Convert BIGINT or UBIGINT cell ID to VARCHAR    
h3_is_valid_cell scalar True if this is a valid cell ID    
h3_is_res_class_iii scalar True if the cell's resolution is class III    
h3_is_pentagon scalar True if the cell is a pentagon    
h3_get_icosahedron_faces scalar List of icosahedron face IDs the cell is on    
h3_cell_to_parent scalar Get coarser cell for a cell    
h3_cell_to_children scalar Get finer cells for a cell    
h3_cell_to_center_child scalar Get the center finer cell for a cell    
h3_cell_to_child_pos scalar Get a sub-indexing number for a cell inside a parent    
h3_child_pos_to_cell scalar Convert parent and sub-indexing number to a cell ID    
h3_compact_cells scalar Convert a set of single-resolution cells to the minimal mixed-resolution set    
h3_uncompact_cells scalar Convert a mixed-resolution set to a single-resolution set of cells    
h3_grid_disk scalar Find cells within a grid distance    
h3_grid_disk_distances scalar Find cells within a grid distance, sorted by distance    
h3_grid_disk_unsafe scalar Find cells within a grid distance, with no pentagon distortion    
h3_grid_disk_distances_unsafe scalar Find cells within a grid distance, sorted by distance, with no pentagon distortion    
h3_grid_disk_distances_safe scalar Find cells within a grid distance, sorted by distance    
h3_grid_ring_unsafe scalar Find cells exactly a grid distance away, with no pentagon distortion    
h3_grid_path_cells scalar Find a grid path to connect two cells    
h3_grid_distance scalar Find the grid distance between two cells    
h3_cell_to_local_ij scalar Convert a cell ID to a local I,J coordinate space    
h3_local_ij_to_cell scalar Convert a local I,J coordinate to a cell ID    
h3_cell_to_vertex scalar Get the vertex ID for a cell ID and vertex number    
h3_cell_to_vertexes scalar Get all vertex IDs for a cell ID    
h3_vertex_to_lat scalar Convert a vertex ID to latitude    
h3_vertex_to_lng scalar Convert a vertex ID to longitude    
h3_vertex_to_latlng scalar Convert a vertex ID to latitude/longitude coordinate    
h3_is_valid_directed_edge scalar True if passed a valid directed edge ID    
h3_origin_to_directed_edges scalar Get all directed edge IDs for a cell ID    
h3_directed_edge_to_cells scalar Convert a directed edge ID to origin/destination cell IDs    
h3_get_directed_edge_origin scalar Convert a directed edge ID to origin cell ID    
h3_get_directed_edge_destination scalar Convert a directed edge ID to destination cell ID    
h3_cells_to_directed_edge scalar Convert an origin/destination pair to directed edge ID    
h3_are_neighbor_cells scalar True if the two cell IDs are directly adjacent    
h3_directed_edge_to_boundary_wkt scalar Convert directed edge ID to linestring WKT    
h3_get_hexagon_area_avg scalar Get average area of a hexagon cell at resolution    
h3_cell_area scalar Get the area of a cell ID    
h3_get_hexagon_edge_length_avg scalar Average hexagon edge length at resolution    
h3_edge_length scalar Get the length of a directed edge ID    
h3_get_num_cells scalar Get the number of cells at a resolution    
h3_get_res0_cells scalar Get all resolution 0 cells    
h3_get_res0_cells_string scalar Get all resolution 0 cells (returns VARCHAR)    
h3_get_pentagons scalar Get all pentagons at a resolution    
h3_get_pentagons_string scalar Get all pentagons at a resolution (returns VARCHAR)    
h3_great_circle_distance scalar Compute the great circle distance between two points (haversine)    
h3_cells_to_multi_polygon_wkt scalar Convert a set of cells to multipolygon WKT    
h3_polygon_wkt_to_cells scalar Convert polygon WKT to a set of cells    
h3_polygon_wkt_to_cells_string scalar Convert polygon WKT to a set of cells (returns VARCHAR)    
h3_is_valid_vertex scalar True if passed a valid vertex ID