Categories:

Geospatial functions

H3_CELL_TO_PARENT

Returns the ID of the parent of an H3 cell for a given resolution. The ID is returned as an INTEGER value (if an INTEGER value was provided as the input ID) or as a VARCHAR containing the hexadecimal ID (if the hexadecimal ID was provided as the input ID).

See also:

H3_CELL_TO_CHILDREN , H3_CELL_TO_CHILDREN_STRING

语法

H3_CELL_TO_PARENT( <cell_id> , <target_resolution> )

实参

cell_id

An INTEGER that represents the H3 cell ID (index (https://h3geo.org/docs/core-library/h3Indexing)), or a VARCHAR that represents the cell ID in hexadecimal format.

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。ID 采用以下格式之一:

  • If cell_id is an INTEGER value, the function returns the ID as an INTEGER value.
  • If cell_id is a VARCHAR value containing the hexadecimal ID, the function returns the hexadecimal ID as a VARCHAR value.

示例

The following example returns the H3 cell ID for the parent of the H3 cell with the ID 613036919424548863 (specified as an INTEGER value):

SELECT H3_CELL_TO_PARENT(613036919424548863, 7);
+------------------------------------------+
| H3_CELL_TO_PARENT(613036919424548863, 7) |
%------------------------------------------%
|                       608533319805566975 |
+------------------------------------------+

The following example returns the H3 cell ID for the parent of the H3 cell with the ID 881F1D4887FFFFF (specified as a VARCHAR value):

SELECT H3_CELL_TO_PARENT('881F1D4887FFFFF', 7);
+-----------------------------------------+
| H3_CELL_TO_PARENT('881F1D4887FFFFF', 7) |
%-----------------------------------------%
|  871F1D488FFFFFF                        |
+-----------------------------------------+