Categories:

Geospatial functions

H3_POLYGON_TO_CELLS_STRINGS

Returns an array of VARCHAR values of the hexadecimal IDs of H3 cells that have centroids contained by a Polygon (specified by a GEOGRAPHY object).

See also:

H3_POLYGON_TO_CELLS_STRINGS , H3_COVERAGE_STRINGS

语法

H3_POLYGON_TO_CELLS_STRINGS( <geography_polygon> , <target_resolution> )

实参

geography_polygon

表示多边形的 GEOGRAPHY 对象。

target_resolution

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

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

返回

返回一个数组,其中包含 H3 单元格十六进制 IDs 的 VARCHAR 值,这些单元格的质心包含在指定的输入多边形中。

使用说明

  • The function uses planar approximation, which treats points on the Earth’s surface as if they were connected by straight lines, rather than curved arcs. If you need a spherical approximation, use H3_COVERAGE_STRINGS instead.
  • 如果单元格的质心包含在多边形内,则认为该单元格位于多边形内。

示例

以下示例返回表示 H3 单元格十六进制 IDs 的 VARCHAR 值 ARRAY,这些单元格的质心包含在指定的多边形中。

SELECT H3_POLYGON_TO_CELLS_STRINGS(
  TO_GEOGRAPHY(
    'POLYGON((-122.481889 37.826683,-122.479487 37.808548,-122.474150 37.808904,-122.476510 37.826935,-122.481889 37.826683))'),
  9) AS h3_cells_in_polygon;
+----------------------+
| H3_CELLS_IN_POLYGON  |
%----------------------%
| [                    |
|   "8928308715bffff", |
|   "89283087397ffff", |
|   "89283087023ffff", |
|   "892830870abffff", |
|   "89283087027ffff", |
|   "89283087033ffff", |
|   "8928308702fffff", |
|   "892830870bbffff", |
|   "89283087037ffff"  |
| ]                    |
+----------------------+