Clustering geo data

One of the main issues when working e.g. with Google maps is to handle the display of many elements. There are 2 things to keep in mind:

  1. Displaying to many elements within the map is confusing and decreases the value of the map view
  2. On the other hand Google maps gets very slwo when handling large amounts of pins

So, mostly the solution is clustering the items together. There are different algorithmns to do that.

For less than 50k this also could be done on the client [2] but for larger amounts clustering has to be done on the server side.

Of course you can implement it by your own but if you are already using elasticsearch there is an easy to use plugin.

I tried that with a simple index:

An example query looks like this:

Does a good job with 400k items in the index and the clusters are at the right place.

Of course also here the calculation of clusters is quite a CPU consuming operation especially on a continent or world view because at the moment it’s implmented similar to closest point brute-force algorithmn. But that one could be solved by optimizing the algorithmn and clever caching.

I will try to cover my cache approach with my next post.

GD Star Rating
loading...

Kommentar verfassen