Categories:

Geospatial functions

H3_LATLNG_TO_CELL

Returns the INTEGER value of the H3 cell ID for a given latitude, longitude, and resolution.

See also:

H3_LATLNG_TO_CELL_STRING

语法

H3_LATLNG_TO_CELL( <latitude> , <longitude> , <target_resolution> )

实参

latitude

表示纬度的 FLOAT。

超出标准纬度范围的值将调整到 [-90,90] 范围。

longitude

表示经度的 FLOAT。

超出标准经度范围的值将调整到 [-180,180] 范围。

target_resolution

An INTEGER between 0 and 15 (inclusive) specifying the H3 resolution (https://h3geo.org/docs/core-library/restable) that you want to use for the returned H3 cell.

指定其他任何 INTEGER 值都会导致错误。

返回

返回与给定位置和分辨率的 H3 单元格 ID 相对应的 INTEGER 值。

使用说明

  • 为任何输入实参指定 NaN 或 Inf 值都会导致错误。

示例

以下示例以分辨率 8 返回勃兰登堡门的 H3 单元格 ID。

SELECT H3_LATLNG_TO_CELL(52.516262, 13.377704, 8);
+--------------------------------------------+
| H3_LATLNG_TO_CELL(52.516262, 13.377704, 8) |
%--------------------------------------------%
|                         613036919424548863 |
+--------------------------------------------+

The following example specifies a longitude value (373.377704) that is outside of the traditional longitude range (-180 to 180). The function interprets this value as 13.377704 (373.377704 modulo 180).

SELECT H3_LATLNG_TO_CELL(52.516262, 373.377704, 8);
+---------------------------------------------+
| H3_LATLNG_TO_CELL(52.516262, 373.377704, 8) |
%---------------------------------------------%
|                          613036919424548863 |
+---------------------------------------------+

下面的示例演示您不能指定 0 到 15 之外的分辨率。

SELECT H3_LATLNG_TO_CELL(52.516262, 373.377704, 18);
100410 (P0000): Invalid H3 resolution value: 18. Resolution must be between 0 (coarsest) and 15 (finest).