Geohash in Trucking and Logistics

Trucking And Logistics Need a New Way To Specify Location – Part 5

This article is the fifth in a series which review the costs and consequences of using street addresses in trucking and transportation then looks at several alternative systems for referring to a location.

The earlier articles covered street addresses, latitude and longitude, and what3words.

This article introduces and reviews a system called “geohash“. The system was invented in 2008 by Gustavo Niemeyer and is in the public domain.

Ultimately, the goal of this series is to identify a location system which meets the following requirements:

  • Uniquely identify a location
  • Uniquely identify one of many tenants at a location
  • Easy to repeat over the phone
  • Easy to understand and type
  • Easy to add to existing systems
  • Can move with a location (because construction, growth, etc)

The geohash system applies a grid to the surface of the earth, dividing it into rectangular areas. Each rectangular area has its own unique identifier. Those identifiers are called a “geohashes” and are a short sequence of numbers and letters.

For example, the geohash code “dp35” represents the area below.

Geohash dp35
Geohash dp35

One neat feature of geohashes is they can represent areas of different size, from nearly 10 million square miles to a square inch. The length of the geocode determines the size of the area represented. Shorter geohashes represent larger areas while longer geohashes represent smaller areas.

A five character geohash (e.g. “dp357“) represents an area of approximately 9.2 mi2, as shown below.

Area represented by a five character geohash
Area represented by a five character geohash

Adding two characters to the geohash indicates a much smaller area. The seven character geohash “dp357zf” represents an area of approximately 27,000 mi2 (5.5 acres), as shown below.

Area represented by a seven character geohash
Area represented by a seven character geohash

Adding two more characters specifies an even smaller area. The nine character geohash “dp357zfgu” represents an area of approximately 27 yard2, a sufficient resolution for most navigational needs.

Area represented by a nine character geohash
Area represented by a nine character geohash

The table below shows the approximate area represented by different length geohashes.

Geohash Approximate Area Represented
Length Example Imperial Metric
1 d 9.65 million mi2 25 million km2
2 dp 301,000 mi2 781,000 km2
3 dp3 9,400 mi2 24,000 km2
4 dp35 294 mi2 762 km2
5 dp357 9.2 mi2 24 km2
6 dp357z 0.28 mi2 0.74 km2
7 dp357zf 27,000 yard2 23,000 m2
8 dp357zfg 871 yard2 729 m2
9 dp357zfgu 27 yard2 23 m2
10 dp357zfgu5 0.8 yard2 0.7 m2
11 dp357zfgu56 34 in2 22,000 mm2
12 dp357zfgu56d 1 in2 691 mm2

Another interesting characteristic is that similar codes will often (but not always) represent nearby areas. For example, the codes “9qh3″ and “9qh9″ represent two adjacent areas.

Geohashes with similar prefixes are generally close to one another
Geohashes with similar prefixes are generally close to one another

Finally, each geohash can be converted into a latitude and longitude and vice versa. The geohash “dn5rw” represents an area centered around 35.09, -85.144. There are open source algorithms available to convert latitude and longitudes to and from geohashes. See for example Geohash encoding/decoding, Geohash utilities in Java on Github, and the Geohash Converter.

With a basic understanding of geohashes, let’s see how they stack up against our requirements:

  • Uniquely identify a location
    Yes, in the sense that a particular geohash represents a specific rectangle area on the surface of the earth. The “expandability” of geohashes give them a fairly unique ability to represent a large or small area
  • Uniquely identify one of many tenants at a location
    Like latitude and longitude and what3words, there is no mechanism to specify an individual tenant in a multi-tenant buildings. The geohash dp3wjz8z refers to the area of the Willis Tower building in downtown Chicago, yet it isn’t specific to any one of the hundreds of business in that building
  • Easy to repeat over the phone
    Yes, reading a geohash over the phone is simply repeating a series of letters and numbers. Importantly, geohashes are case insensitive.
  • Easy to understand and type
    Yes
  • Easy to add to existing systems
    Yes. A geohash requires only a small string (up to 12 characters, typically) in a single field.
  • Can move with a location (because construction, growth, etc)
    No. Like latitude and longitude, a geohash refer to a single area on the surface of the earth. If a business moves, they would need to determine the geohash of their new location and communicate that to their partners.

Overall grade: B.

Next up in this series on location systems is a discussion and review of Google’s “Plus Codes”.

Until then, if you have feedback or thoughts, let me know.