📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ST_HILBERT



Encodes a GEOMETRY or GEOGRAPHY object into a Hilbert curve index. The function uses the center of the geometry's bounding box as the point to encode. When bounds are provided, the point is normalized into the specified bounding box before encoding.

Syntax

ST_HILBERT(<geometry_or_geography>) ST_HILBERT(<geometry_or_geography>, <bounds>)

Arguments

ArgumentsDescription
<geometry_or_geography>The argument must be an expression of type GEOMETRY or GEOGRAPHY.
<bounds>Optional. An array [xmin, ymin, xmax, ymax] used to normalize the point before encoding.

Return Type

UInt64.

Examples

GEOMETRY examples

SELECT ST_HILBERT(TO_GEOMETRY('POINT(1 2)')) AS hilbert1, ST_HILBERT(TO_GEOMETRY('POINT(5 5)')) AS hilbert2; ╭───────────────────────────╮ │ hilbert1 │ hilbert2 │ ├─────────────┼─────────────┤ │ 33554432002155872256 │ ╰───────────────────────────╯ SELECT ST_HILBERT(TO_GEOMETRY('POINT(1 2)'), [0, 0, 1, 1]) AS hilbert1, ST_HILBERT(TO_GEOMETRY('POINT(5 5)'), [0, 0, 5, 5]) AS hilbert2; ╭───────────────────────────╮ │ hilbert1 │ hilbert2 │ ├─────────────┼─────────────┤ │ 28633115302863311530 │ ╰───────────────────────────╯

GEOGRAPHY examples

SELECT ST_HILBERT(TO_GEOGRAPHY('POINT(113.15 23.06)')) AS hilbert1, ST_HILBERT(TO_GEOGRAPHY('POINT(116.25 39.54)')) AS hilbert2; ╭───────────────────────────╮ │ hilbert1 │ hilbert2 │ ├─────────────┼─────────────┤ │ 30702590603033451300 │ ╰───────────────────────────╯ SELECT ST_HILBERT(TO_GEOGRAPHY('POINT(113.15 23.06)'), [73, 4, 135, 53]) AS hilbert1, ST_HILBERT(TO_GEOGRAPHY('POINT(116.25 39.54)'), [73, 4, 135, 53]) AS hilbert2; ╭───────────────────────────╮ │ hilbert1 │ hilbert2 │ ├─────────────┼─────────────┤ │ 35336071942330429279 │ ╰───────────────────────────╯

Was this page helpful?