Skip to content

H3_LATLNG_TO_CELL

Returns the BIGINT value of an H3 cell ID for a supplied latitude and longitude at a given resolution.

Syntax

sql
H3_LATLNG_TO_CELL(<lat>, <long>, <target_resolution>)

Arguments

  • <lat>: A FLOAT4 or FLOAT8 latitude
  • <long>: A FLOAT4 or FLOAT8 longitude
  • <target_resolution>: An integer between 0-15 (inclusive) specifying the H3 resolution of the returned cell

Returns

A BIGINT value corresponding to the H3 cell ID for the given location and resolution. Resolution outside a valid range results in an error.

Example

sql
SELECT h3_latlng_to_cell(0, 0, 3);
-- 592035265791393791