ST_GeoHash - Spectrum_Location_Intelligence_for_Big_Data - 5.2.1

Location Intelligence SDK for Big Data Guide

Product type
Software
Portfolio
Locate
Product family
Spectrum
Product
Spatial Big Data > Location Intelligence SDK for Big Data
Version
5.2.1
Language
English
Product name
Location Intelligence for Big Data
Title
Location Intelligence SDK for Big Data Guide
Copyright
2024
First publish date
2015
Last updated
2024-10-16
Published on
2024-10-16T13:55:01.634374

Description

The ST_GeoHash function returns a unique well-known string ID for the grid cell. The ID then is sortable and searchable that corresponds to the specified X, Y, and precision.

Syntax

ST_GeoHash(Number|String X, Number|String Y, Number precision)

Parameters

Parameter Type Description
X Number or String The longitude value of the point.
Y Number or String The latitude value of the point.
precision Number The length of the string key to be returned. The precision determines how large the grid cells are (longer strings means higher precision and smaller grid cells).

Return Values

Return Type Description
String The geohash ID of the grid cell at the specified precision that contains the point.

Examples

SELECT ST_GeoHash(x, y, precision) FROM table;
SELECT ST_GeoHash("-73.750333", "42.736103", 3);
SELECT ST_GeoHash(-73.750333, 42.736103, 3);
CREATE TEMPORARY TABLE tmptbl AS
   SELECT *, (ST_GeoHash(x, y, 10)) AS hashID
   FROM coordinates ORDER BY hashID;
INSERT INTO TABLE coordinates_with_hash
   SELECT *, (ST_GeoHash(x, y, 10)) AS hashID
   FROM coordinates ORDER BY hashID;
SELECT c.hashID, ST_ToWKT(ST_GeoHashBoundary (c.hashID)), count (*) as quantity 
   FROM (SELECT ST_GeoHash(x, y, 10) AS hashID FROM coordinates) c 
   GROUP BY c.hashID;