v.22.5New Feature

Adds h3Line, h3Distance, and h3HexRing Functions

Adds h3Line, h3Distance and h3HexRing functions. #37030 (Bharat Nallan).
Introduces new H3 geospatial functions: h3Line, h3Distance, and h3HexRing for advanced geospatial queries using the H3 hexagonal hierarchical spatial index system.

Why it matters

These functions extend ClickHouse's support for spatial data by enabling efficient computations and queries using H3 indexes. h3Line allows generating a line of hexagons between two points, h3Distance calculates the distance between H3 indexes, and h3HexRing creates a ring of hexagons at a specified distance. This improves the ability to perform precise spatial queries, analysis, and modeling over geographic data.

How to use it

Use the new functions directly in SQL queries by passing valid H3 indexes and parameters. For example:

SELECT h3Line(h3Index1, h3Index2);
SELECT h3Distance(h3Index1, h3Index2);
SELECT h3HexRing(h3Index, radius);


Make sure your data includes H3 index columns or convert latitude/longitude to H3 indexes before using these functions.