GeoTile Aggregation

I am working on geo data. where I need to show the heatmaps based on aggregation. The data ponts are quite high in volume in any area so looking for some clustering techniques on server side. I came across geotile grid aggregation. -
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geotilegrid-aggregation.html

The response - 

"buckets": [
                {
                  "key" : "8/131/84",
                  "doc_count" : 3
                },
                {
                  "key" : "8/129/88",
                  "doc_count" : 2
                },

I cant understand how these keys are consumed. How google maps will consume these keys on mobile app or is it specific to Elastic Maps?

The output is:

Each cell corresponds to a map tile as used by many online map sites. Each cell is labeled using a "{zoom}/{x}/{y}" format, where zoom is equal to the user-specified precision.

I don't know if google maps knows how to use that but for sure, Kibana does know it.

1 Like

Thanks , Just for the reference can you give me some links how other major map sites can render this response.

{
                  "key" : "8/131/84",
                  "doc_count" : 3
}

I checked Mapbox, Leaflet. We can pass them Geojson data. but not sure how to pass tileid and aggregation count. It will be great if you can point me in the right direction.

No idea. What's wrong with Kibana?

I have to show the maps on mobile apps.

Hi @Nishant_Gauttam,

I'm an engineer on the Kibana team. The GeoTile Grid aggregation returns a key to a specific tile in the Web Mercator coordinate system. There are open source libraries such as SphericalMercator which can convert the tile key to a bounding box.

For heat maps you might want to request a GeoTile aggregation with a higher precision than the current zoom level of the client map. So if the map is on zoom level 8, you may want to set a precision of 10-12 for the geo_grid aggregation. Then you can convert the aggregation results (tile keys & doc_counts) to centroids and use a client-side heatmap generator (ex. Mapbox, Leaflet) to display the results. This is how Elastic Maps creates heat maps.

There are a few examples for converting tile keys to lat lon here. https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Implementations

2 Likes

@nickpeihl, Thanks a ton . Understood it now.
Couple of more points -

  1. How can I find what different tiles a city(washington or newyork) or a bounding box would cover at a certain zoom level. Any easy way to find out all tiles at highest zoom level a city or a bounding box would cover ?
  2. I am planning to precreate geojson for each city at 10-12 zoom level and pass precreated JSON file as response to client for that city. So that client side map libraries can render the heatmaps.

For a quick look at which tiles cover a certain area, I use bboxfinder. For scripting, tilebelt may be useful. It has functions like bboxToTile and getChildren that may help. Perhaps you can use those functions directly or look at the math in the source code to figure out what you need.

thanks @nickpeihl
Also for performance considerations on device is clustering better than heatmap. ?

In your earlier reply you mentioned that For heat maps you might want to request a GeoTile aggregation with a higher precision than the current zoom level of the client map. Dont I have to do same stuff If I do clustering ?

Sorry, I do not have benchmarks on performance of clusters and heatmaps on clients. I think that would depend on which client mapping library you use.

And yes, both clusters and heatmaps would require a higher precision.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.