Calculates a geohash value given two fields representing latitude and longitude.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a] _geohash The name of the field that is produced by the function.
latstringoptional[a] ip.lat The field to use for latitude.
lonstringoptional[a] ip.lon The field to use for longitude.
precisionnumberoptional[a] 12 The precision to use in the calculation. Usually 12 is enough.

[a] Optional parameters use their default value unless explicitly set.

Calculate the geohash value of a set of coordinates.

logscale
geohash(lat=myLatField, lon=myLonField)

geohash() Examples

Click + next to an example below to get the full details.

Calculate Geohash Value of a Set of Coordinates

Calculate a geohash value given two fields representing latitude and longitude using the geohash() function

Query
logscale
londonLat := 51.507222
| londonLon := -0.1275
| geohash(lat=londonLat, lon=londonLon)
Introduction

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
  1. Starting with the source repository events.

  2. 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.

  3. 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:

_geohashlondonLatlondonLon
gcpvj0e5m41551.507222-0.1275