Skip to content

gs1/geocode

Repository files navigation

geocode

GSCN 21-318 will introduce into the next edition of GS1 General Specifications a new GS1 Application Identifier (4309) for Ship-to / Deliver-to Geocode. The expected value is a 20-digit numeric string that encodes WGS84 latitude/longitude coordinates with a precision of around 1.1 centimetres. This is expected to be useful to support the delivery of parcels and logistic units that do not have a conventional postal address.

A demo page is available at https://gs1.github.io/geocode/

Within a barcode, an all-numeric geocode can be encoded more efficiently than a code that requires symbol characters such as + or - or decimal point or alphabetic characters such as N, S, E, W.

Using 20 numeric digits it is possible to encode WGS84 latitude/longitude coordinates with a precision of around 1.1 centimetres.

That's because 0.0000001 degrees corresponds to approximately 1.1cm on the surface of the Earth (2π * 6371,000m / 1E7 / 360.

In this approach we use two 10 digit fields that are concatenated together to form a 20-digit numeric geocode string.

The first ten digits represent latitude measured in decimal degrees northwards from the goegraphic south pole, then multiplied by 10 million and (if necessary) left-padded with '0' digits to reach a total of 10 digits. This approach means that the value is always positive, ranging from 0 at the geographic south pole to 1800000000 at the geographic north pole.

The second ten digits represent longitude measured in decimal degrees east of the Greenwich meridian, then multiplied by 10 million. Locations west of the Greenwich meridian (such as the Hallgrímskirkja in Reykjavik, Iceland) might be considered to have a negative longitude such as -21.926538572471713 but by adding 360°, this can be expressed as a positive longitude such as +338.0734614275. It is this positive longitude value in decimal degrees that is then multiplied by 10 million and (if necessary) left-padded with '0' digits to reach a total of 10 digits.

The following diagrams provide some further explanation of this approach:

Latitude and longitude

Flowchart for encoding latitude and longitude as a 20-digit geocode:

Encoding flowchart

Flowchart for decoding a 20-digit geocode to latitude and longitude:

Decoding flowchart

Summary of formulae:

Formulae summary

Worked Example 1:

Worked example 1

Worked Example 2:

Worked example 2

About

Experimenting with all-numeric geocodes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages