h3_centeraswkt function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 11.3 LTS and above

Returns the center of the input H3 cell as a point in WKT format.

Syntax

h3_centeraswkt ( h3CellIdExpr )

Arguments

  • h3CellIdExpr: A BIGINT expression, or a hexadecimal STRING expression representing an H3 cell ID.

Returns

A value of the type STRING representing the center of the input H3 cell as a point in WKT format.

The function returns NULL if the input expression is NULL. The function does partial validation regarding whether or not the input argument is a valid H3 cell ID. A necessary, but not sufficient condition for a valid H3 ID is that its value is between 0x08001fffffffffff and 0x08ff3b6db6db6db6. The behavior of the function is undefined if the input cell ID is not a valid cell ID.

Error conditions

  • If h3CellIdExpr is a STRING that cannot be converted to a BIGINT or corresponds to a BIGINT value that is either smaller than 0x08001fffffffffff or larger than 0x08ff3b6db6db6db6, the function returns H3_INVALID_CELL_ID.

Examples

-- Input a BIGINT representing a hexagonal cell.
> SELECT h3_centeraswkt(599686042433355775)
  POINT(-121.97637597255 37.345793375368)

-- Input a STRING representing a pentagonal cell.
> SELECT h3_centeraswkt('8009fffffffffff')
  POINT(10.536199075468 64.700000127935)

-- Input is an invalid H3 cell ID.
> SELECT h3_centeraswkt(0)
  [H3_INVALID_CELL_ID] 0 is not a valid H3 cell ID