Description
The GeoHashID 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.
Function Registration
create function GeoHashID as 'com.pb.bigdata.spatial.hive.grid.GeoHashID';
Syntax
GeoHashID(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 GeoHashID(x, y, precision) FROM hivetable;
SELECT GeoHashID("-73.750333", "42.736103", 3);
SELECT GeoHashID(-73.750333, 42.736103, 3);
CREATE TEMPORARY TABLE tmptbl AS
SELECT *, (GeoHashID(x, y, 10)) AS hashID
FROM coordinates ORDER BY hashID;
INSERT INTO TABLE coordinates_with_hash
SELECT *, (GeoHashID(x, y, 10)) AS hashID
FROM coordinates ORDER BY hashID;
SELECT c.hashID, ToWKT(GeoHashBoundary (c.hashID)), count (*) as quantity
FROM (SELECT GeoHashID(x, y, 10) AS hashID FROM coordinates) c
GROUP BY c.hashID;