I want to decide geohash length based on zoom level, how can I do that because so far I am unable to find any standard way to do so?

For example, current zoom level is 10 and geohash is "qyu7652hsze2" of length 12. And, if I zoom out then my zoom level becomes 7 then I want to trim my geohash length by triming 2 ending characters and becomes "qyu7652hsz" of length 10.

I want to apply best practice for this, does anybody know the same?


The best method I've come across on is Geohash Intro

enter image description here

Zooming And Aggregation

If we want to zoom in and out on a map and show a summary of how many points there are on grid square, then we can use a Geohash prefix length that is relative to the zoom resolution

In this example we use a prefix of 2 characters, which will give us the world map divided into 64 (2×32) grid squares, and a count of the number of points found in each one.

SELECT SUBSTR(geohash, 0, 2), COUNT(*) FROM locations GROUP BY SUBSTR(geohash, 0, 2); "aa", 67
"ab", 456
"ac", 128
"ad", 994
"ae", 12
"zx", 0
"zy", 8
"zz", 5

A simple index on the geohash column of the above locations table allows us to focus any queries on specific areas on the map.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.