3

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?

1
  • We can answer this by considering zoom level 98.6 and recognizing that value is nonsensical without a reference. We have to define what scale your zoom level is using. Google maps is a common scale and there are 25 zoom levels from zero to 25. The 32 bit geohash contains but 12 "zoom levels", so we have our conversion factor of 25 to 12 or 12 to 25 going the other way. The "standard" conversion between any units in any domain is to identify the conversion ratio. There is a slight wrinkle here: you will need to round your results to fit into a discrete bucket. – Rick O'Shea Aug 17 '20 at 14:24
2

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.