Categories:

Geospatial functions

H3_COVERAGE

Returns an array of IDs (as INTEGER values) identifying the minimal set of H3 cells that completely cover a shape (specified by a GEOGRAPHY object).

See also:

H3_COVERAGE_STRINGS , H3_POLYGON_TO_CELLS

语法

H3_COVERAGE( <geography_expression> , <target_resolution> )

实参

geography_expression

GEOGRAPHY 对象。

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 cells.

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

返回

返回 INTEGER 值的 ARRAY,适用于已完全覆盖指定输入形状的最小 H3 单元格集的 IDs。

使用说明

  • The function uses spherical approximation, which treats points on the Earth’s surface as if they were connected by arcs, rather than straight lines. If you need a planar approximation, use H3_POLYGON_TO_CELLS instead.
  • 如果单元格的边界与输入形状相交,则该单元格将包含在结果集中。
  • When you apply FLATTEN to the ARRAY returned by the function, cast each value explicitly to an integer.

示例

以下示例返回一个 IDs 的 ARRAY,用于标识完全覆盖指定多边形的最小 H3 单元格集。

SELECT H3_COVERAGE(
  TO_GEOGRAPHY(
    'POLYGON((-122.481889 37.826683,-122.479487 37.808548,-122.474150 37.808904,-122.476510 37.826935,-122.481889 37.826683))'),
  8) AS set_of_h3_cells_covering_polygon;
+----------------------------------+
| SET_OF_H3_CELLS_COVERING_POLYGON |
%----------------------------------%
| [                                |
|   613196571542028287,            |
|   613196571548319743,            |
|   613196571598651391,            |
|   613196571539931135,            |
|   613196571560902655,            |
|   613196571550416895             |
| ]                                |
+----------------------------------+