Calculate Geohash Value of a Set of Coordinates
Calculate a geohash value given two fields representing latitude and longitude using the geohash()
function
Query
londonLat := 51.507222
| londonLon := -0.1275
| geohash(lat=londonLat, lon=londonLon)
Introduction
The geohash()
function is used to calculate a
geohash value given two fields
representing latitude
and
longitude
. These fields and their values can be used
for geohash bucketing to create a World Map for presentation of the
data: lat
, lon
,
geohash
, precision
,
magnitude
In this example, the geohash()
function is used to
calculate the geohash values for London. Note that the values of
latitude and longitude coordinates must be expressed in decimal degrees.
Step-by-Step
Starting with the source repository events.
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0>Augment Data] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;logscale
londonLat := 51.507222 | londonLon := -0.1275 | geohash(lat=londonLat, lon=londonLon)
Calculates the geohash value of a set of coordinates extracted from the fields lat=londonLat and lon=londonLon, and returns the result in a field named _geohash.
Event Result set.
Summary and Results
The query is used to calculate the geohash value for London
(lat
,
lon
). A geohash is used for indexing
locations on maps and in databases.
You can use the worldMap()
function to plot
existing geo-coordinates (latitude/longitude) on the World Map by adding
this to the query:
| worldMap(lat=location.latitude,
lon=location.longitude)
Sample output from the incoming example data:
_geohash | londonLat | londonLon |
---|---|---|
gcpvj0e5m415 | 51.507222 | -0.1275 |