Categories:

Geospatial functions

H3_CELL_TO_BOUNDARY

Returns the GEOGRAPHY object representing the boundary of an H3 cell.

语法

H3_CELL_TO_BOUNDARY( <cell_id> )

实参

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.

返回

返回 GEOGRAPHY 对象,代表具有指定 ID 的 H3 单元格的边界。

示例

以下示例返回 GEOGRAPHY 对象,表示包含勃兰登堡门的 H3 单元格的边界。该示例将 H3 单元格 ID 指定为 INTEGER 值。

SELECT H3_CELL_TO_BOUNDARY(613036919424548863);
+-----------------------------------------+
| H3_CELL_TO_BOUNDARY(613036919424548863) |
%-----------------------------------------%
| {                                       |
|   "coordinates": [                      |
|     [                                   |
|       [                                 |
|         1.337146281884266e+01,          |
|         5.251934565725256e+01           |
|       ],                                |
|       [                                 |
|         1.336924966147084e+01,          |
|         5.251510220405509e+01           |
|       ],                                |
|       [                                 |
|         1.337455447449988e+01,          |
|         5.251214028989955e+01           |
|       ],                                |
|       [                                 |
|         1.338207263166664e+01,          |
|         5.251342164903257e+01           |
|       ],                                |
|       [                                 |
|         1.338428664751681e+01,          |
|         5.251766506194694e+01           |
|       ],                                |
|       [                                 |
|         1.337898164779325e+01,          |
|         5.252062715603375e+01           |
|       ],                                |
|       [                                 |
|         1.337146281884266e+01,          |
|         5.251934565725256e+01           |
|       ]                                 |
|     ]                                   |
|   ],                                    |
|   "type": "Polygon"                     |
| }                                       |
+-----------------------------------------+

以下示例将 H3 单元格 ID 的十六进制值指定为 VARCHAR,以返回与上一示例相同的坐标。

SELECT H3_CELL_TO_BOUNDARY('881F1D4887FFFFF');
+----------------------------------------+
| H3_CELL_TO_BOUNDARY('881F1D4887FFFFF') |
%----------------------------------------%
| {                                      |
|   "coordinates": [                     |
|     [                                  |
|       [                                |
|         1.337146281884266e+01,         |
|         5.251934565725256e+01          |
|       ],                               |
|       [                                |
|         1.336924966147084e+01,         |
|         5.251510220405509e+01          |
|       ],                               |
|       [                                |
|         1.337455447449988e+01,         |
|         5.251214028989955e+01          |
|       ],                               |
|       [                                |
|         1.338207263166664e+01,         |
|         5.251342164903257e+01          |
|       ],                               |
|       [                                |
|         1.338428664751681e+01,         |
|         5.251766506194694e+01          |
|       ],                               |
|       [                                |
|         1.337898164779325e+01,         |
|         5.252062715603375e+01          |
|       ],                               |
|       [                                |
|         1.337146281884266e+01,         |
|         5.251934565725256e+01          |
|       ]                                |
|     ]                                  |
|   ],                                   |
|   "type": "Polygon"                    |
| }                                      |
+----------------------------------------+