Outline
- What is the GeoHash Algorithm and why do we need it?
- How did the GeoHash split the world into a hash array
- The calculating procedure
- Verify the result
Tutorial
1. What is the GeoHash Algorithm and why do we need it?
Geohash is a geographic location coding algorithm that leads us dealing the location task which is popular in many applications and service like LBS or so on, and make it efficiency.
Let’s discuss an application about when you calling a taxi to go somewhere. It’s easy to think that the app service would send a message or request to the nearest driver who could serves you as soon as possible.
Generally, you refresh your location with your country, city and geographic coordinates and let the service known where you are. And the taxi driver would also do this process to upload their position. So, the service in background could calculates the distance between you and the drivers, finding the nearest one to contact you. Quite simple, isn’t it?
Further, let’s put us hands dirty in the process above and check the efficiency. First, we generate 100,001 coordinates in longitude and latitude. One of these is your position, and the rest of these are the driver’s. I put our Python script below so you could copy it to your own .ipynb file and go ahead.
1 | import numpy as np |
Here, we have prepared the simulation data and be ready for the next step. In this step, we will find out 10 drivers near you. So, let’s do it by the codes below.
1 | import math |
2. How did the GeoHash split the world into a hash array?
3. The calculating procedure
4. Verify the result
References & Documentations
GeoHash Wikipedia
https://en.wikipedia.org/wiki/Geohash
GeoHash Explorer
Author: 徐奕峰 Eephone Xu