Geocoding and postal codes

The problem

Many software developers have misconceptions about postal codes (usually referred to as zipcodes in the United States) and how they relate to geographic areas.

We hope that this guide will help cast light on some of the common misconceptions, and thus help prevent developers from building applications based on faulty logic.

One of the most common problems we see is developers struggling when the assumptions they made about postcodes based on their home country turn out not to be valid in other countries.

Background

The key point to understand is that postal codes are a tool used by postal services to speed up the delivery of physical mail. In some parts of the world postal codes have become a shorthand way to refer to areas, and this has lead to a mistaken, albeit understandable, perception that postcodes always correspond to locations.

Common points of confusion and misconceptions

Postcodes always represent locations

No, for most countries postcodes represent mail delivery points. Those points may or may not be in fixed locations. For example, many countries assign postcodes to military units. The postcodes stays the same regardless of where the unit is physically based. In many countries large companies or government departments have their own postal code with no correlation to physical location.

Postcodes never move or change

No, in most countries there is on-going fluctuations in postcodes. New postcodes are created, old codes are retired, large organization move and take their code with them. Occasionally countries will change their entire postcode system (fun!).

Within a country the area covered by a postcode is always roughly the same size

No, absolutely not. Generally postcodes cover roughly the same number of people. In a dense city that might by a very small area. In a rural area it may be massive.

Postcodes work roughly the same way in all countries

No, not at all. Almost every aspect of what a postcode is and what it means can differ across countries. The format of the code, the number of people it represents, etc, etc.

All countries have postcodes

No, many countries do not have any form of postal code at all. Also, some countries technically have a postcode system, but it is not widely used.

Every geographic location belongs to a certain, unique postcode region.

While some countries have assigned postcode regions to all of their territory, many others have not. Remote locations, for example in a large forest, or lakes or other bodies of water, may not fall into any postal region.

Locations have a single, unique postcode

No, often large buildings will have multiple postcodes, for example if there are multiple, large organizations based there. Usually it will depend on how many people are at the location (and thus how much mail typically needs to be sent there). An example: skyscrapers in Manhattan, New York City can have multiple "zipcodes" (as postcodes are known in the US). Also, when postcodes change people will often keep using the old postcode, even after a new postcode has been assigned to the location.

The area covered by a postcode is always within one state / province

In many countries the area served by a postcode has no correspondence with administrative hierarchies like county, state, province, etc. In Australia the postcode 0872 famously spans not just multiple states but also timezones.

Postal systems are unique to a specific country

No, many countries and territories of the world use the postal service of other countries. For example Liechtenstein uses the Swiss postal system. For logistical convenience, exclaves of one country often use the postal system of another country. For example the German exclave Büsingen uses both the German and Swiss postal services.

Postcodes are unique to a specific country

No, many countries use strings of numbers as their postal code. So if you just send us a query like 12345 we have no idea which country you mean. Please always also add a country name. For example: 12345, USA

Postcodes are always numbers

No, many countries like the UK, Canada, and the Netherlands have alphanumeric codes. But even in countries that use only digits in their postal codes it is best to always treat postcodes as strings not numbers, otherwise leading zeros can get removed by formatting software (for example Excel). This is one of the most common problems we see in geocoding query formatting.

Postcodes are always alphanumeric

No, some countries require dashes or spaces in their codes. For example in Poland postal codes are five digits but with a dash between the second and third digit, for example: 01-003.

So what should software developers do?

The first thing is you should understand and internalize that postcodes are not a great tool for communicating location. They should be avoided if possible. Nevertheless, we understand that in some countries the habit of searching by postcode or referring to locations by postcode has become entrenched.

Even in that case it's important to understand the inherent limitations and challenges of using postcodes to reference locations. Know the potential problems you are building into your system.

If your application will be geocoding multiple countries do NOT fall into the trap of assuming postal codes have the same characteristics in all countries (or even that all countries have postcodes)

Final point: treat postcodes as string not numbers. You will thank us.

Further Reading

Happy geocoding!

Start your free trial

2,500 geocoding API requests per day.

No credit card required.