0 through 2^level - 1. Coordinates outside the supplied extent are clipped to its nearest edge. A zero-width axis maps to grid coordinate zero. Z and M coordinates do not affect the result.
Use the same extent and level for geometries whose keys you want to compare. Different geometries whose envelope midpoints map to the same grid position receive the same key.
Signatures
Parameters
Geometry
required
The input geometry. The function uses the midpoint of its envelope, not its centroid.
Double
required
The minimum X coordinate of the extent used to scale the midpoint.
Double
required
The minimum Y coordinate of the extent used to scale the midpoint.
Double
required
The maximum X coordinate of the extent used to scale the midpoint.
Double
required
The maximum Y coordinate of the extent used to scale the midpoint.
Integer
required
The curve level. Levels 1 through 16 provide increasingly fine ordering keys. For a non-empty geometry, a level at or below zero returns zero. A level above 16 raises an error.
Return type
A non-negative Hilbert address. At level 16, the maximum value is
4294967295.NULL, the result is NULL. An empty geometry raises an error because it has no envelope midpoint, including when the level is zero or negative.
How addresses are assigned
At level 2, the extent becomes a 4-by-4 grid. The Hilbert curve visits every cell once and assigns addresses from 0 through 15 along that continuous path:Examples
Envelope midpoint
The polygon’s envelope midpoint is(0.5, 0.5). Within the unit-square extent at level 2, it maps to address 2:

