Location technology

    How Location Codes Are Generated From Coordinates

    A general explanation of how a latitude and longitude become a short code: gridding the Earth, numbering cells and encoding the number.

    Updated 14 October 2026 · 3 min read

    A grid-based location code is made by dividing the Earth into small cells, finding which cell contains your coordinates, and writing that cell's number in a compact, readable form. The process is repeatable: the same coordinates always produce the same code, and every point inside one cell shares the same code.

    Step 1: choose a reference system

    The code must start from a consistent set of coordinates. In practice this is latitude and longitude on WGS 84, the same system that GPS and web maps use. If inputs came from different systems, the same place could land in different cells.

    Step 2: lay a grid over the world

    The grid has a fixed cell size. One way is to divide latitude and longitude into equal steps of a small angle. Another is to use a projected plane with a size in metres. Either way, every position can be assigned to a cell using integer maths:

    • Take the latitude and shift it so that the range starts at zero (add 90).
    • Divide by the cell height and drop the fractional part. This gives a row index.
    • Do the same for longitude (add 180) to get a column index.

    Two whole numbers now identify the cell.

    Step 3: combine into a single number

    The row and column can be merged into one number by placing them side by side or interleaving their digits. Interleaving, as used in geohash, keeps nearby cells numerically close. Either way, the result is one unique number per cell.

    Step 4: write the number as a code

    A long number is awkward to say or type, so it is converted to a different base using a chosen alphabet of letters and digits. Designers usually drop easily confused characters, such as the letter O and the digit 0. The code can then be grouped with separators, and a prefix such as a country can be added for readability and quick validation. UPCS codes, for instance, take the form CC-XXXX-XXXX with a two-letter country prefix and two blocks of letters and digits.

    Reversing the process

    Decoding is the same maths in reverse: convert the characters back to a number, split it into row and column, and compute the cell's boundaries and centre. The result is an area, not a single point, which is why a decoded code is shown with a single representative position for the cell.

    Why the cell size matters

    The smaller the cells, the longer the code needed to cover the globe, and the higher the precision. A cell that is too large cannot separate neighbouring entrances; one that is too small asks for more accuracy than devices can give. See why a 3 metre grid cell is practical.

    Comparing real systems

    Different systems vary the grid, the alphabet and the format. Compare Plus Codes, MGRS and word-based systems to see the design choices in practice.

    Frequently asked questions

    Will the same coordinates always give the same code?

    Yes. A grid-based code is a deterministic function of the position, so identical coordinates give the identical code.

    Can two nearby points get the same code?

    Yes, if they fall in the same cell. Every point inside a cell shares that cell's code.