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

ST_GEOHASH



Return the geohash for a GEOMETRY or GEOGRAPHY object. A geohash is a short base32 string that identifies a geodesic rectangle containing a location in the world. The optional precision argument specifies the precision of the returned geohash. For example, passing 5 for `precision returns a shorter geohash (5 characters long) that is less precise.

Syntax

ST_GEOHASH(<geometry_or_geography> [, <precision>])

Arguments

ArgumentsDescription
<geometry_or_geography>The argument must be an expression of type GEOMETRY or GEOGRAPHY.
[precision]Optional. specifies the precision of the returned geohash, default is 12.

Return Type

String.

Examples

GEOMETRY examples

SELECT ST_GEOHASH( ST_GEOMETRYFROMWKT( 'POINT(-122.306100 37.554162)' ) ) AS pipeline_geohash; ┌──────────────────┐ │ pipeline_geohash │ ├──────────────────┤ │ 9q9j8ue2v71y │ └──────────────────┘ SELECT ST_GEOHASH( ST_GEOMETRYFROMWKT( 'SRID=4326;POINT(-122.35 37.55)' ), 5 ) AS pipeline_geohash; ┌──────────────────┐ │ pipeline_geohash │ ├──────────────────┤ │ 9q8vx │ └──────────────────┘

GEOGRAPHY examples

SELECT ST_GEOHASH( ST_GEOGFROMWKT( 'POINT(-122.306100 37.554162)' ) ) AS pipeline_geohash; ┌──────────────────┐ │ pipeline_geohash │ ├──────────────────┤ │ 9q9j8ue2v71y │ └──────────────────┘

Was this page helpful?