Categories:

Geospatial Functions

H3_COMPACT_CELLS_STRINGS¶

Returns an array of VARIANT values that contain the VARCHAR hexadecimal IDs of fewer, larger H3 cells that cover the same area as the H3 cells in the input. For information about compacted cells, see Indexing.

Syntax¶

H3_COMPACT_CELLS_STRINGS( <array_of_cell_ids> )
Copy

Arguments¶

array_of_cell_ids

An array of VARIANT values that contain the VARCHAR hexadecimal values that represent H3 cell IDs (indexes).

Returns¶

Returns a value of the ARRAY data type or NULL.

  • If the input is an array of VARCHAR hexadecimal values, returns an array that consists of VARIANT values that represent a compacted set of H3 cells. The VARIANT values contain the VARCHAR hexadecimal values that represent H3 cell IDs.

  • If the input is NULL, returns NULL without reporting an error.

Usage notes¶

  • All of the VARCHAR hexadecimal values in the input must represent valid H3 cells.

  • All of the H3 cells in the input must have the same resolution.

  • The H3 cells in the input must cover unique areas without overlapping. Duplicate H3 cells are not allowed.

Examples¶

The following example compacts a set of H3 cells, returning cells at a lower resolution that represent the same area.

SELECT H3_COMPACT_CELLS_STRINGS(
  [
    '8a2a10705507fff',
    '8a2a1070550ffff',
    '8a2a10705517fff',
    '8a2a1070551ffff',
    '8a2a10705527fff',
    '8a2a1070552ffff',
    '8a2a10705537fff',
    '8a2a10705cdffff'
    ]
  ) AS compacted;
Copy
+----------------------+
| COMPACTED            |
|----------------------|
| [                    |
|   "8a2a10705cdffff", |
|   "892a1070553ffff"  |
| ]                    |
+----------------------+