Geohash prefixes and cell edges
medium 4 minGeohash encodes a location in hierarchical rectangular cells.
Video lesson · Chapter 1 of 5
The two riders cross a prefix line
A 20-metre neighbour with a different prefix
1:12Reel
Theory
Read or listen first. About 1 min.
What it is
A geohash prefix names a rectangular region. Two nearby points on opposite sides of its edge receive different prefixes even when their separation is tiny.
A charger just across a prefix boundary
Why it exists
A radius query needs a covering of all intersecting cells followed by a distance check. Looking only inside the starting cell creates a gap precisely at its boundary.
Words to know
- Cell covering
- A set of cells whose union contains the requested geographic area.
How it works
Step through the idea, or press Play.
Encode. Convert a charger location into a hierarchical cell key.
Understand it
Worked example
Geohash prefixes and cell edges in practice
A driver is ten metres from a neighboring cell. Scanning only the driver’s prefix omits a charger twenty metres away across that edge. Cover the search area and apply an exact distance test.
Related case
Find every charger across a cell boundary
A driver near the edge of a grid cell requests chargers within 800 metres. The closest charger sits across the street in another cell.
Fetch intersecting cells and check candidates.