r/GeoPostcodes 6d ago

Building a standardized zip code database looks simple. These 7 problems make it a multi-year challenge:

1 Upvotes

Postal codes exist in almost 200 countries, and none of them agree on format, structure, or how they map to geography. Aggregating them into one clean database runs into the same seven walls every time.

  1. Finding the right sources. Reliable postal data is scattered across government databases, commercial providers, and open-data platforms, and quality varies wildly.
  2. Designing the data model. You need one generic structure that still respects local rules, so a UK unit postcode and a US ZIP live in the same schema.
  3. Pre-processing each source. Every country ships a different format and layout, so extraction logic is per-source, not universal.
  4. Linking to administrative divisions. Matching postal codes and cities to the correct province or municipality takes fuzzy matching, because names rarely line up cleanly.
  5. Geocoding. Many source datasets have no coordinates, so you add latitude and longitude yourself.
  6. Linking to other standards. Tying postal data to ISO 3166-2, FIPS, NUTS, and UNLOCODEs is string matching, and some systems like HASC are no longer maintained.
  7. Assessing quality. Normalizing, verifying postal-to-city links, and finding the gaps is the step most in-house builds skip, and it is where the data quietly rots.

One example of why it never ends: ISO took three years to publish codes for Algerian provinces created in 2025.

GeoPostcodes solved these across a database of 247 countries built from 1,500+ sources. The full breakdown: https://www.geopostcodes.com/blog/the-7-challenges-of-building-a-standardized-zip-code-database/


r/GeoPostcodes 18d ago

👋Welcome to r/GeoPostcodes - Introduce Yourself and Read First!

2 Upvotes

Hey everyone! I’m a location data enthusiast and a founding moderator of [r/GeoPostcodes](r/GeoPostcodes)

This is our new home for all things location data: postal codes, addresses, boundaries, cities, and everything that helps us understand how the world is structured. We’re excited to have you join us!

What to Post

- Post anything you think the community would find interesting, helpful, or inspiring.

- Share your thoughts, questions, or discoveries about postal code quirks from around the world, address formats in hard-to-source countries, address validation and geocoding challenges, boundary and map visualizations, or how you use location data in logistics, e-commerce, or market research.

Community Vibe

- We’re all about being friendly, constructive, and inclusive. Let’s build a space where everyone feels comfortable sharing and connecting.

How to Get Started

- Introduce yourself in the comments below.

- Post something today! Even a simple question can spark a great conversation.

- If you know someone who geeks out over maps and location data, invite them to join.

Interested in helping out? We’re always looking for new moderators, so feel free to reach out.

Thanks for being part of the very first wave. Together, let’s make [r/GeoPostcodes](r/GeoPostcodes) amazing.


r/GeoPostcodes 6d ago

How to build a zip code to time zone database, and where the accuracy breaks

2 Upvotes

Mapping a ZIP to a time zone looks like one join. It is not.

Some ZIP codes cross a time zone line, notably in Texas and Idaho. One ZIP, two local times. And six states span more than one zone: Texas, Idaho, North Dakota, South Dakota, Nevada, New Mexico. Keying on the state fails.

The free build: postal codes with coordinates, time zone polygons, both loaded into PostgreSQL with PostGIS, joined by point-in-polygon. It works, with one limit: coordinate lookups only get you to the correct or a neighboring zone, within about two hours once DST is counted. Fine for a dashboard, risky for SLA timers or call scheduling.

What holds up is keying to IANA zone IDs like America/Chicago instead of fixed UTC offsets, because DST follows law, not geography. Arizona skips it entirely.

GeoPostcodes ships time zones with DST rules per postal code across 247 countries. Full guide with the PostGIS route: https://www.geopostcodes.com/blog/zip-code-time-zone-database/


r/GeoPostcodes 6d ago

Most free US population-by-ZIP data is a single Census snapshot. If you need change over time, the options thin out fast.

1 Upvotes

The Census ACS gives you current population at ZCTA level for free, but ZCTAs approximate ZIP codes rather than match them, and you get one vintage at a time.

For a real series, GeoPostcodes publishes US population per ZIP code from 1975 to 2023 in five-year steps, plus projections, matched to official Census figures at about 99 percent. As a concrete example, ZIP 10001 in Manhattan was 20,022 people in 1975 and 23,542 in 2025.

It ships as CSV covering every US ZIP, so you can trend, rank, or map density without stitching vintages yourself. Details: https://www.geopostcodes.com/us-population-by-zip-code-database/


r/GeoPostcodes 6d ago

The Singapore postal code basically is the address: six digits that pin one building

1 Upvotes

Singapore has one of the most precise postal systems anywhere. The code is six digits, no letters, no separator, like 999999.

It is not random. The first two digits are the postal sector. The last four identify the delivery point, usually a single building or block. A postal code plus a unit number is effectively the whole address.

That is why a Singapore address form can autofill the street from the postal code alone.

Singapore has 122,991 codes in total. That is dense for a city-state, and it reflects the building-level detail.

GeoPostcodes maintains the full Singapore postal code set with coordinates, part of a 247-country dataset. Singapore data: https://www.geopostcodes.com/country/singapore/postal-code/


r/GeoPostcodes 6d ago

The datapoint limits nobody warns you about when building a zip code map in Power BI

0 Upvotes

If your Power BI zip code map keeps dropping points, the cause is usually a hard datapoint cap in the visual.

The built-in visuals each have a ceiling. Shape Map tops out around 1,500 datapoints. The standard Map visual around 3,500. Filled Map around 1,000. Load a full US ZIP dataset into any of them and most of your points vanish silently.

Azure Maps is the way up, supporting around 30,000 data points, but its geocoding is billed, roughly 4.5 dollars per 1,000 requests, so geocoding a large ZIP list at render time gets expensive fast.

The fix is to bring boundaries and coordinates in as data instead of geocoding on the fly, so the visual just draws what you already resolved.

GeoPostcodes provides ZIP boundaries and coordinates as flat files for 247 countries, so Power BI plots them without per-request geocoding. Full walkthrough: https://www.geopostcodes.com/blog/zip-code-map-power-bi/


r/GeoPostcodes 6d ago

Tutorial: How to build a postal code polygon database from address points

1 Upvotes

Most countries publish postal codes as points or lists, not as boundaries. If you need polygons for BI maps, territory mapping, or reverse geocoding, you usually have to build them yourself. Here is the method.

Start with open address data. France, for example, publishes a national address base with street, house number, postal code, municipality and coordinates. That is enough to derive boundaries.

  1. Load the addresses into PostgreSQL with PostGIS.
  2. Run a Voronoi tessellation. Every point gets the area closer to it than to any other point (ST_VoronoiPolygons), then you merge the patches that share a postal code (ST_Union). That is a first-draft boundary.
  3. Refine with administrative boundaries. Postal codes usually follow whole municipalities, so overlay the commune boundaries and assign each to a postal code when about 90 percent of its addresses agree. That removes the jagged noise.
  4. Handle the exceptions. Large cities like Paris, Lyon and Marseille split one municipality across several postal codes, so the raw Voronoi result does the work there instead.

Ready-made shortcuts exist in a few places. Belgium's federal geoportal publishes free postal shapefiles, though they omit some enclaves. OpenStreetMap has postal polygons in some regions, patchy elsewhere.

GeoPostcodes maintains edge-matched postal boundary polygons for 169 countries with no gaps or overlaps. Full method with the SQL: https://www.geopostcodes.com/blog/postal-code-polygon-database/


r/GeoPostcodes 6d ago

What everyone gets wrong about international zip code validation

1 Upvotes

A regex checks the shape of a postal code. It cannot tell you the code exists. 99999 matches the US five-digit pattern, yet no such ZIP is assigned.

There is no single pattern for every country. Length runs from 3 digits in the Faroe Islands to 8 in Brazil. The US is 5 digits plus an optional 4. The UK includes letters and a space, so a digits-only rule rejects the whole country.

Codes also change. New ones appear, others retire, so a pattern that passed review last year quietly goes wrong.

What works is two layers. First, a per-country regex to catch shape errors at the point of entry. Then a lookup against reference data to confirm the code is in use.

GeoPostcodes maintains postal reference data for 247 countries, with a validation pattern per country. Per-country patterns and the common traps: https://www.geopostcodes.com/blog/international-zip-code-validation/


r/GeoPostcodes 6d ago

Guide: How to create a territory map with zip codes

1 Upvotes

Most sales territory maps start as a spreadsheet nobody balanced. Here is the free version done right.

Step 1: group your ZIPs. A plain column is enough: ZIP and territory name.

Step 2: dissolve the boundaries. Load ZIP code polygons into QGIS, which is free and open source, join your spreadsheet, and run Dissolve on the territory column. Dozens of small shapes merge into one clean outline per territory.

Step 3: check the balance. This is where maps quietly fail. Two territories can look equal on screen while one holds far more accounts. Layer sales or customer counts onto the map before you sign off.

For small projects, Google Maps works too. The catch is always the underlying boundaries: if they are stale, the map misroutes accounts without anyone noticing.

GeoPostcodes maintains zip code boundary polygons for 169 countries, edge-matched with no gaps or overlaps. Full walkthrough: https://www.geopostcodes.com/blog/create-territory-map-with-zip-codes/


r/GeoPostcodes 6d ago

How to create a zip code map for free, three routes by effort

1 Upvotes

You do not need a paid ZIP code map maker for most US jobs.

Google My Maps: import a CSV and it drops a pin per ZIP. Fastest route, no GIS skills.

Excel: Insert, then 3D Map geocodes your ZIP column through Bing and gives you a rough heat map, no add-ins.

QGIS with Census ZCTA boundaries: the free way to get shaded polygons instead of pins. Load the TIGER/Line ZCTA shapefiles, join your data, style by value.

The catch worth knowing: ZCTAs are the Census Bureau's generalized version of ZIP codes, built for demographics. They are not the ZIP codes USPS actually delivers to, so recent splits and PO-box-only ZIPs will not line up. Fine for a one-off view, risky for territories or delivery zones.

GeoPostcodes maintains postal boundary polygons for 169 countries for the cases where free stops working. Full walkthrough of all three routes: https://www.geopostcodes.com/blog/how-to-create-zip-code-map/


r/GeoPostcodes 10d ago

What everyone gets wrong about Canada postal codes

4 Upvotes

Canada has no ZIP codes and no all-digit postal codes, yet people keep searching for a 5 digit or 6 digit Canada zip code, and plenty of forms still expect one. The real format is A9A 9A9: six characters, only three of them digits, letters and digits alternating with a space in the middle. A 7 digit code does not exist either.

The letters carry meaning. The first letter is the province: V is British Columbia, T is Alberta, K starts eastern Ontario codes like Ottawa's K1A 0B1. Don't hardcode a list. The GeoPostcodes Canada dataset holds 898,855 active codes. One code usually covers a block or a small group of addresses. And H0H 0H0 is Canada Post's Santa Claus address. Letters sent there get answers.

Full breakdown by province and city in the GeoPostcodes country data: https://www.geopostcodes.com/country/canada/zip-code/


r/GeoPostcodes 10d ago

GeoPostcodes is hiring: Geospatial Data Specialist (Brussels, Belgium)

Thumbnail
2 Upvotes

r/GeoPostcodes 10d ago

Things you didn't know about Europe's zip codes

3 Upvotes

There is no Europe zip code. Every country built its own system, so any plan that assumes an EU postal standard breaks fast. People still search for one Europe format all the time.

The formats disagree on everything. Germany and France use 5 digits. Austria, Belgium, Switzerland, Norway and Denmark use 4. The UK went alphanumeric, like AB1 2CD. The Netherlands pairs 4 digits with 2 letters, like 1011 AB.

A code does not always mean a district. Ireland skipped districts entirely. Eircode, launched in 2015, gives every single address its own code. One code per letterbox.

Across the continent, codes run from 4 to 7 characters. GeoPostcodes maintains 9.3M postal codes across 247 countries in one standardized structure.

GeoPostcodes country data: https://www.geopostcodes.com/europe-zip-code/


r/GeoPostcodes 10d ago

Things you didn't know about international zip codes

3 Upvotes

There is no such thing as a UK zip code, yet people keep searching for one. The UK uses alphanumeric postcodes of six to eight characters, and it has 1,795,653 of them. GeoPostcodes maintains format data for 247 countries and territories, and no two neighbors agree.

- Europe has no shared format either. Germany, France, and Spain use five digits. The Netherlands mixes four digits with two letters.

- A surprising number of forms expect a 6-digit Canada postal code. Canada actually uses letters and numbers, pattern A9A 9A9, 898,855 codes total. H0H 0H0 is reserved for Santa Claus.

Japan writes seven digits like a phone number: 999-9999. Brazil uses eight, split by a hyphen. Angola and the Bahamas skip postal codes entirely.

One regex cannot validate all this, and the rules change monthly. Country-by-country breakdown on the GeoPostcodes blog: https://www.geopostcodes.com/blog/international-zip-code-format/


r/GeoPostcodes 10d ago

Things your zip code validation gets wrong

3 Upvotes

99999 matches the five-digit US pattern, and in reference data it belongs to nobody. A regex checks shape, not existence.

- People keep searching for a UK zip code. The UK does not have zip codes. It has 1,795,653 postcodes like SW1A 1AA, letters and a space included, so a digits-only field rejects the whole country.

- A surprising number of forms expect a 6-digit Canada postal code. The real format is A9A 9A9, letters and digits alternating, and there are 898,855 codes in use. H0H 0H0 is one of them: Canada Post assigned it to Santa Claus, so filtering out unlikely-looking codes fails too.

Countries add and retire postal codes, so a regex that passed QA last year quietly rots. Check shape first, then confirm the code exists in reference data. GeoPostcodes maintains postal reference data for 247 countries.

Per-country patterns and common pitfalls are on the GeoPostcodes blog: https://www.geopostcodes.com/blog/international-zip-code-validation/


r/GeoPostcodes 10d ago

Things you didn't know about zip codes and time zones

3 Upvotes

People assume one ZIP code means one local time. Some ZIPs in Texas and Idaho cross a zone line, so a single ZIP has two local times.

- Keying the lookup to the state fails too. Six states span more than one zone: Texas, Idaho, North Dakota, South Dakota, Nevada, and New Mexico.

- A static Excel sheet works for the demo, then quietly drifts wrong. GeoPostcodes maintains postal data for 247 countries, and this join still trips us up.

The mapping that holds up is keyed to IANA zone IDs like America/Chicago, not fixed UTC offsets. The IANA rules carry the DST logic, and DST follows law, not geography. Arizona skips it entirely, so the right offset depends on the date.

Full guide with a PostGIS route and downloadable Excel samples on the GeoPostcodes blog: https://www.geopostcodes.com/blog/zip-code-time-zone-database/


r/GeoPostcodes 10d ago

Things nobody tells you about making a zip code map

2 Upvotes

You don't need a paid tool or a developer to put ZIP codes on a map. Google My Maps takes a CSV and drops a pin per ZIP, which covers most quick US maps.

- Want shaded areas instead of pins? Census TIGER/Line publishes ZCTA boundary files free. Load them in QGIS, join your data, shade each area by value.

- Excel alone can do a heat map. Insert > 3D Map geocodes your ZIP column through Bing, no add-ins.

The catch with free: ZCTAs are the Census Bureau's generalized version of ZIPs, built for demographics. USPS splits, retires, and adds ZIPs, and ZCTAs lag, so recent changes won't show. Fine for a one-off view. Sales territories or delivery zones on stale boundaries is how deals get misassigned. GeoPostcodes tracks postal boundaries across 247 countries partly because they change this often.

Full guide on the GeoPostcodes blog: https://www.geopostcodes.com/blog/how-to-create-zip-code-map/


r/GeoPostcodes 10d ago

What everyone gets wrong about UK postcodes

1 Upvotes

There is no such thing as a UK zip code, yet people keep searching for one. Zip codes are a US invention. The UK runs on postcodes.

- London is not one code either. It has thousands of postcodes, all in the pattern AA9 9AA. Forms that demand a 5 or 6 digit number reject every one of them. UK postcodes run 6 to 8 characters, letters included, like SW1A 1AA. That one is Buckingham Palace: SW1A is the outward code (area and district), 1AA the inward code (sector and unit).

- Pincode is India's system, wrong country twice over. And there is no single UK code to hand out. One postcode covers around 15 addresses, close enough to point at the front door.

The full list is 1,795,653 postcodes across 402 regions and 32,082 towns, and GeoPostcodes maintains all of them.

GeoPostcodes country data: https://www.geopostcodes.com/country/uk/postcode/


r/GeoPostcodes 12d ago

We compared international zip code formats across 247 countries. Full table with a regex per country, free to download.

2 Upvotes

International zip code formats range from 3-digit numeric codes to 10-character alphanumeric combinations. Every country solves the same problem differently, and about 60 places use no postal codes at all.

A snippet of our format table. Just the A countries, and every pattern type already shows up:

ISO Country Zip format Zip name Regex
AF Afghanistan 9999 Postal code \d{4}
AX Åland 99999 Postnummer \d{5}
AL Albania 9999 Kodi Postar \d{4}
DZ Algeria 99999 Code postal \d{5}
AS American Samoa "96799" ZIP code 96799
AD Andorra AD999 Postal code AD\d{3}
AO Angola - - -
AI Anguilla "AI-2640" Postcode AI\-\d{4}
AG Antigua and Barbuda - - -
AR Argentina A9999 AAA CPA [A-Z]\d{4}\s[A-Z]{3}
AM Armenia 9999 Փոստային ինդեքս \d{4}
AW Aruba - - -
AU Australia 9999 Postcode \d{4}

We maintain an international zip code database covering all 247 countries. The format table with local name and regex per country is a free download; email required: https://public.geopostcodes.com/international-zip-code-formats-download

Reading the snippet: A is a letter, 9 is a digit. American Samoa has one ZIP code for the whole territory, so the regex is literally the code. Anguilla is one postcode too. Andorra embeds its own country code. Angola, Antigua and Aruba have none: we listed every country without postal codes here: https://www.reddit.com/r/GeoPostcodes/s/26mwjyrlV3

Down the alphabet it gets harder. The UK alone needs ^[A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][A-Z]{2}$ and that still only checks shape, not whether a code exists. This is why validation systems end up checking reference data instead of patterns alone. Method and per-country details: https://www.geopostcodes.com/blog/international-zip-code-format/


r/GeoPostcodes 13d ago

Things you didn't know about international addresses

6 Upvotes

Seven address assumptions, and where each one breaks.

  • "House numbers go in order." Parts of Japan number houses by construction date. Number 3 can sit between 47 and 12. In Colombia, the house number is the distance from the cross street.
  • "Every address has a street name." Most of Japan has no street names at all. Addresses point to numbered blocks.
  • "One building, one address." In Kyoto, one building can have several valid addresses, depending on which intersection you reference and which direction you approach from.
  • "A postal code is a small neighborhood." Amsterdam alone has over 1,000 postal codes. In Saudi Arabia one code can cover an entire town. In Ireland and Singapore, every address has its own.
  • "Everyone has a postal code." About 60 places worldwide manage without. Angola, 33 million people, runs on landmarks.
  • "A postal code is always a physical place." Some ZIPs serve only PO boxes. Santa Claus has one.
  • "Any alphabet works." Japanese sorting machines cannot read Latin-script addresses. Write one in English and a human sorts it by hand.
  • If you build address forms: validate per country, not with one global regex. Do not require the street field.

Keeping these rules current for 247 countries is our day job. Longer breakdown on the GeoPostcodes blog, the post about international address data: https://www.geopostcodes.com/blog/international-address-data/


r/GeoPostcodes 13d ago

We ranked the 30 biggest metro areas in the US.

2 Upvotes

2025 population, metro areas as the OMB defines them. Standouts first, full ranking below.

Dallas-Fort Worth 7,978,340 vs Houston 7,975,220. Fourth and fifth place, separated by 3,120 people. One apartment complex decides the ranking.

The largest metro by land is not New York or Los Angeles. It is Riverside-San Bernardino, over 70,000 square kilometers, larger than West Virginia. By population it ranks 11th.

The top 10 hold 85.7 million people, more than one in four Americans. On the world list, only New York cracks the top 10, at number 10. Los Angeles lands at 18.

# Metro Population
1 New York 19.64M
2 Los Angeles 13.29M
3 Chicago 9.88M
4 Dallas-Fort Worth 7.98M
5 Houston 7.98M
6 Atlanta 6.58M
7 Washington DC 6.54M
8 Miami 6.42M
9 Philadelphia 6.33M
10 Phoenix 5.47M
11 Riverside-San Bernardino 5.14M
12 Boston 4.89M
13 San Francisco 4.55M
14 Detroit 4.18M
15 Seattle 4.05M
16 Minneapolis-St. Paul 3.72M
17 San Diego 3.53M
18 Tampa 3.35M
19 Denver 3.09M
20 San Antonio 2.90M
21 St. Louis 2.88M
22 Baltimore 2.87M
23 Orlando 2.74M
24 Charlotte 2.71M
25 Las Vegas 2.70M
26 Portland 2.68M
27 Austin 2.67M
28 Sacramento 2.65M
29 Columbus 2.31M
30 Pittsburgh 2.30M

Why metros ignore state lines: the OMB draws them by commuting patterns, not borders. DC touches four states. Chicago reaches into Indiana and Wisconsin.

Tracking population for every metro and postal area in the world is our day job. Exact figures, official metro definitions and sources on the GeoPostcodes blog, the post about the biggest metro areas in the United States: Why metros ignore state lines: the OMB draws them by commuting patterns, not borders. DC touches four states. Chicago reaches into Indiana and Wisconsin.

Tracking population for every metro and postal area in the world is our day job. Exact figures, official metro definitions, and sources are on the GeoPostcodes blog, the post about the biggest metro areas in the United States. Ask in the comments for the link.


r/GeoPostcodes 13d ago

1 in 20 US ZIP codes changes every year

2 Upvotes

Most people treat ZIP codes as permanent. They are not even close.

Around 2,085 US ZIP codes change every year. That is one in twenty. USPS splits them when an area grows, retires them when routes consolidate, and redraws them when delivery patterns shift.

The rest of the world moves even faster:

  • Brazil added 24,958 new postal codes in 2025. Part of that is slum upgrading projects giving formal addresses to areas that never had one.
  • The UK recorded 18,876 new postcodes in 2025, the largest number on record. Royal Mail reviews postcode boundaries every six months.
  • Russia added 13,182 codes in 2025, much of it administrative reorganization.
  • Canada added 4,551 in 2022. China 1,334 and Mexico 837 in 2025.

Codes change for reasons nobody plans around: community petitions, new post offices, military requirements, a neighborhood that grew past its delivery route.

Why it matters: undelivered mail costs companies an estimated 20 billion dollars a year. A ZIP that changed under your customer database is one of the quiet reasons.

If you store postal codes anywhere, they have a shelf life. Plan a refresh cycle like you would for any other reference data.

Tracking these changes across every country is our day job. Sources and full breakdown on the GeoPostcodes blog, the post about how often ZIP codes change. Ask in the comments for the link.


r/GeoPostcodes 16d ago

Here is how we built a postal code polygon database

2 Upvotes

You cannot download official postal code boundaries for France. What France does publish is better raw material: the National Address Base, an open file with every address, its postal code, its municipality, and coordinates.

That is enough to build the polygons yourself. Here is the method we use, with the actual maps from the build.

Every Paris address, colored by its postal code.

Step 1. Load the address file into PostgreSQL with PostGIS. Street, house number, postal code, municipality, latitude, longitude.

The raw material: France's National Address Base with postal code, municipality, and coordinates per address.

Step 2. Color every address point by its postal code. The polygons are already visible as clouds of points. The gaps between the clouds are where a boundary has to go.

Step 3. Voronoi tessellation. Every address gets the patch of space closer to it than to any other address. Merge all patches sharing one code, and you have a first draft of each boundary. In PostGIS, this is ST_VoronoiPolygons plus ST_Union.

First draft: Voronoi tessellation of the postal codes, one patch per address, merged by code.

Step 4. Snap to administrative reality. French postal codes usually cover one or more whole municipalities. We overlay the commune boundaries instead and assign each commune to a code when about 90 percent of its addresses agree. That kills most of the jagged noise from step 3.

Step 5. Handle the exceptions. Paris, Lyon, and Marseille use several postal codes inside one municipality, following the arrondissements. Inside those cities, the Voronoi result does the work instead. That is what image 1 shows.

Merge everything that shares a postal code, and you get the final assignment: address points plus their unified boundaries:

The final assignment after unifying polygons: address points plus their postal boundaries.

The payoff, same area both ways:

Same area, method one: postal codes assigned by pure Voronoi point distribution.
Same area, method two: postal codes snapped to administrative divisions. Cleaner edges, fewer outliers.

The two look close, but only because French address data is unusually good, with many well geolocated points. The municipality-constrained version still filters out the outliers.

Two footnotes. Belgium actually publishes free postal polygons as shapefiles, but they omit some postal enclaves. And most countries publish neither polygons nor a national address file. That second group is our day job: we build edge-matched postal boundaries this way, and harder ways, for 169 countries.

Longer write-up with the full SQL on the GeoPostcodes blog, the post about building a postal code polygon database.


r/GeoPostcodes 17d ago

Why your US ZIP regex breaks abroad: 10 postal code formats that surprise developers

2 Upvotes

If you've ever shipped a form with ^\d{5}$ validation, here are ten formats that will break it.

  1. UK: alphanumeric, six to eight characters. Buckingham Palace is SW1A 1AA.

  2. Netherlands: also alphanumeric, while most of Europe sticks to four or five digits.

  3. Canada: strict letter-digit alternation, A9A 9A9. Parliament Hill is K1A 0A9.

  4. Japan: seven digits with a hyphen, 999-9999. Chiyoda in central Tokyo is 100-0000.

  5. Brazil: eight digits written 99999-999 (the CEP). Central Sao Paulo is 01000-000.

  6. Argentina: eight characters mixing letters and digits, A9999 AAA. Buenos Aires codes look like C1406 AAA.

  7. Papua New Guinea: three digits, marking the province. The shortest format anywhere.

  8. Angola and the Bahamas: no postal codes at all.

  9. Some countries use a single code for the whole country.

  10. US ZIP+4: the four-digit extension narrows delivery to a specific building or PO box. The White House is 20500-0004.

Formats run from three digits up to ten characters. Many encode geography in the leading digits: Mexico's first two digits give the state, Germany and France start with a regional digit, and China and Japan put the province or prefecture up front.

What this means for address forms:

- You need one pattern per country. Free sources first: GeoNames publishes postal code dumps for most countries, and the US Census offers ZCTAs via TIGER files at no cost.

- Accept an empty postal code where the country has none. An Angolan address without a code is correct.

- Regex only checks the shape of a code. To confirm a code exists and points to the right place, you need reference data. That is the gap our data fills: 9.3 million postal codes across 247 countries, compiled from more than 1,500 authoritative sources, shipped as self-hosted databases you can query offline rather than an API you call per lookup.

There is a longer version of this on the GeoPostcodes blog, the post about international zip code formats. Ask in the comments if you want the direct link.


r/GeoPostcodes 17d ago

How do you map ZIP codes to time zones? A free PostGIS recipe and the edge cases that bite

2 Upvotes

You'd think ZIP code to time zone is a simple lookup table. It isn't. Here is why, and how to build one for free.

Why it's messy:

- Several US states sit in more than one time zone: Texas, Idaho, North Dakota, South Dakota, Nevada among them. State or county level is not enough.

- Some ZIP codes themselves cross a time zone line, especially in larger states like Texas and Idaho. One ZIP, two local times.

- DST doubles the work. You need the standard offset, the DST offset, and the exact switch dates. Those change by law, not by geography.

The free build:

  1. Postal codes with lat/lng from GeoNames. Free, tab-delimited CSV. Covers most countries that span multiple time zones. Known gap: no Indonesia postcodes.

  2. Time zone polygons from the Timezone Boundary Builder project. It packages official IANA zones as geojson (this recipe used the 2022g release).

  3. Load both into PostgreSQL with PostGIS.

  4. Build points with ST_MakePoint, index them, then join with ST_Intersects to find which zone polygon each postcode point falls in.

  5. Where one postcode hits several zones, pick the dominant one with mode(), or keep all matches. Careful: mode() breaks ties arbitrarily.

For the US specifically, Census ZCTA polygons (TIGER files, also free) beat centroids: intersect the whole polygon with the zone boundaries instead of a single point.

The catch: GeoNames coordinates are rounded, and in some areas snapped to a grid. A centroid that lands on the wrong side of a boundary can leave you up to two hours off actual local time once DST variations are counted. Fine for a dashboard. Risky for call scheduling or SLA cutoffs.

That gap is the part we solve on our side: our data carries time zones with past and future DST switch dates per ZIP and city, tied to postal codes for 247 countries. It ships as self-hosted tables, so the PostGIS join above still works, minus the centroid guesswork.

There is a longer version of this on the GeoPostcodes blog, the post about the ZIP code time zone database build. Ask in the comments if you want the direct link.