Geohash string (geohashstr)
Description
Transforms a latitude/longitude geocoordinate or geohash of geocoord data type to a geohash of string data type.
Learn more about geocoords and their types in the Geocoord (geocoord) article.
How does it work in the search window?
Select Create column in the search window toolbar, then select the Geohash string operation.Â
This operation has only one required argument - this is the column containing the geocoord input values. When the input argument is of geocoord data type, there is an optional second argument, Size, that lets you specify the length of the geohash output in characters. The default length is 8 characters.
Argument | Description | Data type |
---|---|---|
Geocoord mandatory | Choose the field containing the input geocoordinate values. You can select either sexagesimal longitude/latitude values or a set of geohashes. | geocoord |
Size | Specify the length of the output string geohashes in characters. If not specified, the default length is 8 characters. If the input geocoord value is a geohash and the size specified is longer than the input value, the output geohash will be padded on the right with zeros. | integer |
The data type of the new column containing is string.
Example
In the demo.ecommerce.data
table, we have a column called Geocoord of data type geocoord containing latitude/longitude geocoordinates. This was created by first using the Geolocated Latitude and Geolocated Longitude operations to get the latitude and longitude of each IP address. Then using the Latitude and longitude coordinates operation to combine them into sexagesimal coordinates of data type geocoord.Â
We want to transform these sexagesimal coordinates into 6-character precision geohashes of data type string. Click Create column and select the Geohash string operation. Select the Geocoord column as the Geocoord argument. Add a second argument, Size, and enter 6. Click Create Column.
The result is a column containing 6-character precision geohash values in the string data type.
How does it work in LINQ?
Use the operator select
... as
... and add the operation syntax to create the new column. These are the valid formats of the Geohash string operation:
geohashstr(geocoord)
geohashstr(geocoord, int)
Example
Copy the following LINQ script and try the above example on the demo.ecommerce.data
 table.Â
from demo.ecommerce.data
select mmlatitude(clientIpAddress) as latitude,
mmlongitude(clientIpAddress) as longitude,
latlon(latitude, longitude) as geocoord
select geohashstr(geocoord, 6) as geocoord_strings