A prototype under development by @astronomyblog/@ODILeeds

Geocode

A code for everywhere on Earth.

Our Geocodes are based on a hierarchical gridding of a sphere. A Geocode can be calculated for anywhere using mathematics. The advantages of this approach are:

Features

How does Geocode compare to other systems for finding location?

Coding systemOpenFreeNo DB neededGlobal coverage?Widely used?Privacy*Equal area
Geocode
UK Postcodes
Plus codes
What 3 Words~
Latitude/longitudeN/A

* Privacy is possible by limiting how much of the code is shared. For UK postcodes it is possible to provide a sector (e.g. LS8 1), an outcode (e.g. LS8), or even just an area (e.g. LS) to preserve more and more privacy. Geocodes reduce the resolution by about a factor of 4 for ever character removed. Longitude and latitude reduce by a factor of 10 for every digit removed. What 3 Words cannot be reduced from the maximum precision. Plus Codes of different lengths can encode at several spatial scales.

How is the Geocode calculated?

The Geocode is derived from the Hierarchical Equal Area isoLatitude Pixelisation (HEALPix) gridding of a sphere. This splits the sphere up into 12 diamonds (four around each of the poles are four around the equator). Each of these 12 diamonds is split up into 16 pixels. Each of these pixels can be further subdivided into 16 more and this process repeated until the desired spatial resolution is reached - each subdivision increases the spatial resolution by a factor of four. At any given level in the hierarchy, the pixels are of equal area. The pixel centres sit on a discrete number of latitude circles, with equal spacing around each.

For a desired spatial resolution (NSIDE) and latitude/longitude we calculate the HEALPix hierarchical pixel number, px. The first job is to establish which of the 12 base resolution pixels the point is in. We have assigned these the characters:

We have avoided using I because it could easily be confused with 1. With this lettering, much of Africa will start with A and much of Europe will start with E. Most of C is in the Pacific Ocean!

Now that we have the first character of our Geocode we need to find the rest of it. The number of pixels within a base resolution pixel, pxperface, is NSIDE×NSIDE. The pixel number within the base resolution pixel, s, is found from px % pxperface. We find the pixel number (0-15) within this level and represent it with a hexadecimal character (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F) which we append to our Geocode. We then divide the pxperface by 16 and recalcuate s. We repeat this division process until pxperface is less than 16. We should now have the Geocode at the required resolution (NSIDE).

For example, ODI Leeds is based in central Leeds near 53.7969°, -1.5342°. With an NSIDE of 65536, the HEALPix pixel number is 14853107420. This puts it in base resolution pixel H (to the west of 0° longitude) which has 4294967296 pixels. s is 1968205532 and the code for this zoom level is given by floor(pxs*s/pxperface) i.e. 7. We now divide pxperface by 16 and re-calculate s as 89157340. Repeating the process for next zoom level adds a 5. At this point, the code is H75 and that covers a large part of northern England, parts of North Wales, the east coast of Ireland, and parts of Southern Scotland. The next level adds another 5 (a region including Leeds and parts of North Yorkshire). We can keep stepping down until pxperface is under 16. The end result, at NSIDE of 65536 is H75506EF1. This is slightly longer than a UK postcode but has the advantages listed above.

We've made a small, stand-alone, Javascript library for calculating a Geocode: odi.geocode.js.