What is Geohashing?
Published: 2023-11-27 16:03:38

Geohashing (or geohash) is a [geocoding](https://www.pubnub.com/learn/glossary/what-is-geocoding-and-reverse-geocoding/) method used to encode geographic coordinates (latitude and longitude) into a short string of digits and letters delineating an area on a map, which is called a cell, with varying resolutions. The more characters in the string, the more precise the location.

### What is an example of a geohash?

Geohash is a public domain of encoding coordinates. An example of a geohash is the coordinate pair 28.6132,77.2291 being converted into a geohash of ttnfv2u. 

### What is the maximum length of a geohash?

The maximum length of a geohash is 12.

How Does Geohashing Work?
-------------------------

### Geohash algorithm and calculation

Geohashes use Base-32 alphabet encoding (characters can be 0 to 9 and A to Z, excl "A", "I", "L" and "O”). Imagine the world is divided into a grid with 32 cells. The first character in a geohash identifies the initial location as one of the 32 cells. This cell will also contain 32 cells, and each one of these will contain 32 cells (and so on repeatedly). Adding characters to the geohash sub-divides a cell, effectively zooming in to a more detailed area.

![](https://images.ctfassets.net/3prze68gbwl1/assetglossary-17su9wok1ui0z7r/55420735eef7b0469e22092fdc0683f4/geohashing-large-scale-example.jpeg)

The precision factor determines the size of the cell. For instance, a precision factor of one creates a cell 5,000km high and 5,000km wide, a precision factor of six creates a cell 0.61km high and 1.22km wide, and a precision factor of nine creates a cell 4.77m high and 4.77m wide (cells are not always square).

![](https://images.ctfassets.net/3prze68gbwl1/assetglossary-17su9wok1ui0z7s/54cff1f40a461b1019b02cf1c35b542a/geohashing-examples-san-francisco.png)

Geohashing Examples and Use Cases
---------------------------------

Geohashing was originally developed as a [URL-shortening service](https://bitly.com/) but it is now commonly used for spatial indexing (or spatial binning), location searching, mashups and creating unique place identifiers.

### Geohash benefits

A geohash is shorter than a regular address, or latitude and longitude coordinates, and therefore easier to share, remember and store.

-   **Social Networking:** Chat with people near you within a particular cell, and to [create chat apps](https://www.pubnub.com/learn/glossary/what-is-in-app-chat/).
    
-   **Proximity Searches:** Find nearby locations using [API mapping](https://www.pubnub.com/learn/glossary/what-is-a-map-api/) or [geolocation APIs](https://www.pubnub.com/learn/glossary/what-is-a-geolocation-api/) and identify places of interest, restaurants, shops and accommodation establishments in an area.
    
-   **Digital Travels:** Geohashers go on global expeditions to meet people and explore new places. The twist: the destination is a computer-generated geohash and participants in this turnkey travel experience have to write up and post their story on the internet.
    
-   **Custom Interactive Apps:** Geohashing can be used to create [real-time, interactive apps](https://www.pubnub.com/blog/connected-shared-experiences-a-developers-guide/).
    

You can try it out [here](https://www.movable-type.co.uk/scripts/geohash.html). Use the coordinates 40.748440989 and -73.985663981 for a view of the area around the Empire State Building in New York. Change the precision factor to increase or decrease the resolution (size of the cell), or use the geohash dr5ru6j2c5fqt for a 13-digit precision factor to zoom right in.

### What are the drawbacks to using a geohash?

The drawbacks to geohashing include:

1.  Using a grid based geohashing algorithm does need meet high-precision requirements
    
2.  Geohashing deviation changes as latitude increases because the Earth is an irregular ellipse.
    

Ready to incorporate real-time functionality in your app? [Create a free PubNub account today](https://admin.pubnub.com/#/register).

Other Resources
---------------

-   [Geolocation and Geotracking](https://www.pubnub.com/learn/glossary/what-is-a-geolocation-api/)
    
-   [React Native Geolocations Tracking App](https://www.pubnub.com/blog/realtime-geo-tracking-app-react-native/)
    

How can PubNub help you?
========================

This article was originally published on [PubNub.com](https://pubnub.com/guides/what-is-geohashing/)

Our platform helps developers build, deliver, and manage real-time interactivity for web apps, mobile apps, and IoT devices.

The foundation of our platform is the industry's largest and most scalable real-time edge messaging network. With over 15 points-of-presence worldwide supporting 800 million monthly active users, and 99.999% reliability, you'll never have to worry about outages, concurrency limits, or any latency issues caused by traffic spikes.

Experience PubNub
-----------------

Check out [Live Tour](https://www.pubnub.com/tour/introduction/) to understand the essential concepts behind every PubNub-powered app in less than 5 minutes

Get Setup
---------

Sign up for a [PubNub account](https://admin.pubnub.com/signup/) for immediate access to PubNub keys for free

Get Started
-----------

The [PubNub docs](https://www.pubnub.com/docs) will get you up and running, regardless of your use case or [SDK](https://www.pubnub.com/docs)