greatCircleDistance
Returns the distance between two points on the surface of the Earth, in meters, using the great-circle (spherical) model. Faster but slightly less accurate thangeoDistance (ClickHouse only).
Syntax
lon1Deg,lon2Deg— Longitude of each point, in degrees, in the range [-180, 180].lat1Deg,lat2Deg— Latitude of each point, in degrees, in the range [-90, 90].
- The distance between the two points, in meters (Float64). Roughly 111,195 m per degree of latitude.
Users within 50 km of a city center
geoDistance
Returns the geodesic distance between two points on the WGS-84 ellipsoid, in meters. This is more accurate thangreatCircleDistance for real-world distances (ClickHouse only).
Syntax
lon1Deg,lon2Deg— Longitude of each point, in degrees, in the range [-180, 180].lat1Deg,lat2Deg— Latitude of each point, in degrees, in the range [-90, 90].
- The distance between the two points, in meters (Float64).
Distance from each user to a fixed store
pointInPolygon
Returns whether a point lies inside a polygon defined by its vertices. Behavior on the polygon boundary is undefined (ClickHouse only). Syntax(x, y)— The point to test, as a tuple of coordinates (Tuple).[(a, b), (c, d), ...]— The polygon, as an array of vertex tuples forming a closed ring (Array of Tuple).
- 1 if the point is inside the polygon, 0 otherwise (UInt8).
Users inside a bounding-box polygon
greatCircleAngle
Returns the central angle between two points on a sphere, in degrees, using the great-circle (haversine) formula (ClickHouse only). Syntaxlon1Deg,lon2Deg— Longitude of each point, in degrees.lat1Deg,lat2Deg— Latitude of each point, in degrees.
- The central angle between the two points, in degrees (Float64).
Central angle between two coordinates
geoToH3
Returns the H3 cell index for the given latitude, longitude, and resolution. H3 is a hierarchical hexagonal geospatial grid, useful for bucketing points into cells (ClickHouse only). Argument order is(lat, lon, resolution) on ClickHouse v25.5 and later; earlier versions took (lon, lat, resolution).
Syntax
lat— Latitude of the point, in degrees (Float64).lon— Longitude of the point, in degrees (Float64).resolution— H3 grid resolution, in the range [0, 15], where 0 is coarsest and 15 is finest (UInt8).
- The H3 cell index (UInt64), or 0 on error.
Bucket users into H3 cells at resolution 7
h3IsValid
Returns whether the given number is a valid H3 cell index (ClickHouse only). Syntaxh3index— The H3 cell index to check (UInt64).
- 1 if the value is a valid H3 index, 0 otherwise (UInt8).
Keep only valid H3 cells