Skip to main content

Categories: String, Geospatial, Conversion

ST_FROMGEOHASH

Decodes a Geohash string and returns a struct with Latitude and Longitude fields for the center of the Geohash. Inverse of ST_GEOHASH.

Syntax​

ST_FROMGEOHASH(geohash varchar) → struct<latitude: double, longitude: double>​

  • geohash: A valid base32-encoded Geohash string.

Examples

ST_FROMGEOHASH example
SELECT ST_FROMGEOHASH ('ezs42')
-- {'Latitude': 42.60498046875, 'Longitude': -5.60302734375}
ST_FROMGEOHASH example
SELECT ST_FROMGEOHASH ('9q9j8ue2v71y5zzy0s4q')
-- {'Latitude': 37.554162000000034, 'Longitude': -122.30609999999993}
ST_FROMGEOHASH example
SELECT ST_FROMGEOHASH ('ezs42')['latitude']
-- 42.60498046875
ST_FROMGEOHASH example
SELECT ST_FROMGEOHASH ('ezs42')['longitude']
-- -5.60302734375
Decode a geohash for Venice, Italy
SELECT ST_FROMGEOHASH('u20f80')
-- {'Latitude': 45.44219970703125, 'Longitude': 12.3101806640625}
Decode a shorter, less precise geohash
SELECT ST_FROMGEOHASH('u20')
-- {'Latitude': 45.703125, 'Longitude': 11.953125}
Decode a geohash for San Francisco, California
SELECT ST_FROMGEOHASH('9q8yyk')
-- {'Latitude': 37.77374267578125, 'Longitude': -122.4151611328125}