Free The Postcode
From OpenStreetMap
This page documents things relating to http://www.freethepostcode.org/, a free database of postcode-to-location mappings. They are asking people with GPS Receivers to submit their copyright-free lattitude/logitude readings for any particular postcode.
Clearly this is a Related Project, overlapping quite nicely with some of the activities of OpenStreetMap, so we can help each other out.
User:Randomjunk has created a postcode map, which displays postal areas on top of an OSM map, based on 'Free The Postcode' data: http://dev.openstreetmap.org/~random/postcodes/
See also OpenStreetMap FAQ which has some information relevant to FreeThePostcode.
Contents |
How to easily get postcodes
Enter postcodes as waypoints in your GPS unit. Then when you get home you can go through them and send them to freethepostcode. If you don't know the postcode, it's fairly easy to figure out well-known places. For example, take a waypoint outside a pub then go and google for the pubs address. Bingo, you have the postcode.
A good source of post codes is phone boxes. In some parts of the UK most phone boxes have their full postal address on a small label inside (this is so that a caller can tell the emergency services where they are).
Another good source is businesses with local branches/stores (banks, supermarkets, etc). Most have a list of stores (with postcodes) on their web site.
Geocoder
The basic geocoder can get from postcode to lat/lon and back:
- http://www.freethepostcode.org/geocode?postcode=n1%201aa
- http://www.freethepostcode.org/geocode?lat=52.0&lon=1
The postcode geocoder knows not to fall back on N-something if you ask it for NW-something. It will give you the closest match it can. You can make it better by collecting more postcodes. The format should be pretty obvious and not subject to change. Lines starting with a hash are comments, see also http://www.freethepostcode.org/currentlist
Feature requests
- Enter OSGB coords rather than lat/lon
- Enter eastings and westing rather than positive and negative numbers
- Enter coords in degrees, minutes, seconds
- Not just UK - eg freethepostcode.org/norway
- Upload by GPX waypoint names (would need to validate postcode formats vs waypoint names, and many Garmin GPS receivers only allow 6 character waypoint names, which means only a subset of UK postcodes can be done this way). This avoids co-ordinate keying errors.
- Accuracy information - eg if a user requests OX1 4AU then if we don't have an exact match we can return a location based on OX1 4xx or OX1 xxx or OXx xxx with an estimated error based on average sizes of zone/district etc.
- this is already done, the geocoder returns the best match available and tells you which one it's giving back, try it :-)
- Sure, but this isn't good enough for an end-user application where we want to say "this postcode is here, plus or minus xx m/km". The implication here is that we need to store some information about the size of each postcode zone. --Dom.
- This is an issue for non-residential codes especially - my work postcode covers a site about 500m across. Should I measure the postcode somewhere in the middle of the site (looking the postcode up on google maps etc provides a point vaguely, but not exactly in the middle) or should I provide the location of the actual entrance? Even the latter is difficult, as the visitors' entrance used to be on one side of the site, and is now on the other... --DA
- Incidentally, can we have a mailing list for freethepostcode? It'd make this sort of discussion easier --Dom.
- Allow people to amend postcodes they enter, or at least to reject codes when the confirmation email arrives. I very stupidly put in the wrong coords whilst going through a list I gathered, and ignored the email but trying it a second time with the right coords doesn't seem to have worked -- Tom.
Schema
This might need some different approaches for different countries
(From [1] and [2] with comments)
UK
a(a)n(n|a) naa
the initial alpha(s) are a mnemonic for city or region. All of Northern Ireland is BTn(n), despite containing several cities. London on the other hand is divided into several regions. Quite complex to parse/validate. Mnemonic look-up tables will be needed.
Girobank post codes are an exception (GIR naa) - see the PAF digest The first part of the postcode is known as the "Outward" part, and the second part is the "Inward" part. Typically, the "Outward" part relates to one, and only one postal town, though there are some exceptions.
UK coverage is being tracked at Free The Postcode UK Coverage
UK Overseas Territories
aaaa 1ZZ
Several of the UK's Overseas Territories have now been allocated a postocode (one single postcode per territory). They are a four letter code (based on the territory name), followed by 1ZZ. Wikipedia has an apparently full list of them.
IE
Dublin n(n)('W')
The Republic of Ireland currently does not use postcodes at all, the closest thing being the Dublin and Cork Postal Districts, of which only the Dublin ones are ever used on letters. A Dublin postal district is similar to the old pre-postcode UK ones, and is included on the postal town address line in the format "Dublin 15".
Odd-numbered postal districts (1-17) are north of the river Liffey, even-numbered ones (2-24 and 6W) south (with slight spillover in at least one river-spanning suburb). Dublin 6W is an anomaly to the system caused by address snobbery triggered by a boundary adjustment that threatened to include an upmarket district with its more downmarket neighbours.
Cork's postal districts go from 1 to 4.
A project is in progress to devise and implement a countrywide postcode scheme, with 2008 the currently suggested date for a rollout. Although details of the scheme are not yet clear, Postcodes are likely to be street-level and at least at townland resolution in rural areas.
LV
Latvian post codes are managed by Latvian Post. Code consists with letters LV and for digits like LV-xxxx If code is in Riga then it is in interval 1000 - 2000. Outside Riga codes are bigger than 2000.
You can find any Latvias post code by goin this link
NL
nnnn-aa
the first two digits denote city or region; the remainder denotes the delivery route, down to street side and segment. There is a scheme that uses a check digit to denote odd street number, even street number, or even boat moorings, which is easy enough to implement to check validity of addresses.
FR
nnnnn
the first two digits denote department, as also used for vehicle number plate suffix. Not street level.
DE
nnnnn
not street level. (areas)
The number denotes a 'Zustellbezirk' (postal district)
- 1. Number: Zone
- 2. Number: Region
- 3-5 : district
Postcodes are assigned by the German Post, as suited best for their postal needs:
Most of the time a city or commune has just one number.
Bigger cities have more than one (Frankfurt/Main: 37 between 60311 - 60487)
Villages may share one number with other villages or a town nearby.
- The number can have leading zeros because 0 is a valid zone
- The postal districts have no relation to the city districts
- The postal districts may exceed the borders of counties or even federal states
- Single locations may use the postcode of the nearby office which delivers post best, even if located within another postal area otherwise.
- There can be seperate numbers for P.O. Boxes or large institiutions (e.g. businesses receiving large ammount of mail) where no real street or geolocation can be assigned.
- A street might pass more than one postal district
PLZ City Street No City District 60316 Frankfurt Berger Str. 1-105 Nordend-Ost 60316 Frankfurt Berger Str. 2-124B Nordend-Ost 60385 Frankfurt Berger Str. 107-181 Nordend-Ost 60385 Frankfurt Berger Str. 126-190 Nordend-Ost 60385 Frankfurt Berger Str. 183-999 Bornheim 60385 Frankfurt Berger Str. 192-998 Bornheim
BE
nnnn
Each commune has his one. The two first numbers give the province.
So,
10nn 11nn 12nn are for Brussels
13nn 14nn are for the Brabant Wallon
15nn 16nn 17nn 18nn 19nn are for Vlaams-Brabant
2nnn are for Antwerpen
30nn 31nn 32nn 33nn 34nn are also for Vlaams-Brabant
35nn 36nn 37nn 38nn 39nn are for Limburg
4nnn are for Liège
5nnn are for Namur
60nn 61nn 62nn 63nn 64nn 65nn are for Hainaut
66nn 67nn 68nn 69nn are for Luxembourg
7nnn is also for Hainaut
8nnn are for West-Vlaanderen
9nnn are for Oost-Vlaanderen
SE
nnn nn
Not street level, usually in densly populated areas a street have more than one postcode, but where the population is more sparse there might be many streets per postcode. I did a fast count of the number of people per postcode and came up with 1000 per number, in Stockholm.
US
(aa) nnnnn(-nnnn)
the alphas denote state, the nnnnn seem to be low in the Eastern US, high in the West. The -nnnn suffix brings zipcodes down to street level.
CA
ana nan
Accurate to street segment and side if the second digit is non-zero. If the second digit is zero, it is generally a small town post office.
The first digit indicates the province, roughly east to west:
- A = Newfoundland
- B = Nova Scotia
- C = Prince Edward Island
- E = New Brunswick
- F,G,H,J = Quebec
- G[1-9] = Quebec City
- H[1-9] = Montreal
- K,L,M,N,P = Ontario
- M[1-9] = Toronto
- R = Manitoba
- S = Saskatchewan
- S7 = Saskatoon
- T = Alberta
- V = British Columbia
- WXYZ? (NWT, Yukon, Nunavut?)
(I used to sort mail for a living, but it was a long time ago. I've only put what I'm fairly sure of, but please correct any mistakes.)
IT
nnnnn
On a general basis, they are on town level. Just Milano, Roma, Bologna, Napoli, and Torino have street level granularity.
AU
nnnn
To a rough approximation, the first digit 2-7 covers six states (2=NSW, 3=VIC, 4=QLD, 5=SA, 6=WA, 7=TAS) with territories either 0nnn or 2nnn. See wikipedia page. The Australian postcode database is a zero-cost download from Australia Post, but with copyright and usage restrictions.
ES
nnnnn
A Spanish post code (Código Postal) consists of five digits, the first two digits are derived from an alphabetical list of the 50 Spanish provinces - starting at 01nnn for Álava/Araba and ending at 50nnn for Zaragoza. Post codes 51001 to 51005 are used for addresses in Ceuta and 52001 to 52006 for addresses in Melilla - the Spanish controlled enclaves in Morrocco. Slightly confusingly post codes for the Asturias start with the digits 33nnn (rather than 05nnn) because formerly, was known by it's capital city's name, Oviedo. That's also the case of Cantabria (39nnn) which was formerly known as Santander or La Rioja (26nnn) by Logroño.
HR
HR-nnnnn
Shown format is ISO format for postal code use in Croatia, in standard use is also 5 digits number without "HR-" prefix.
The code is divide by biger city in whic Croatian Post have major distributing center :
10000 Zagreb Area 20000 Dubrovnik Area 21000 Split Area 22000 Šibenik Area 23000 Zadar Area 31000 Osijek Area 32000 Vukovar Area 33000 Virovitica Area 34000 Požega Area 35000 Slavonski Brod Area 40000 Čakovec Area 42000 Varaždin Area 43000 Bjelovar Area 44000 Sisak Area 47000 Karlovac Area 48000 Koprivnica Area 49000 Krapina Area 51000 Rijeka Area 52000 Pazin Area 53000 Gospić Area
Mostly Post use central city of County for distributing center. Also Croatian telecom use first two digits for prefix nuber when you call phone number in Croatia.
Postal code is assigne to post office, not particulary for area, so it will be nice to submit cordinate of postal office with exact postal code.
All code are freely available (and very accur) on Croatian Post web pages.
CN
nnnnnn
TW
nnnnn or nnn.
I had fun exploring the Taiwan Post Office's postal code CDROM. They hand it out free at the post office, and one finds no copyright notice on it. The CDROM is better than their website, http://www.post.gov.tw/ , which doesn't expose the innards.
SI
nnnn
Top level post codes:
1000 Ljubljana 2000 Maribor 3000 Celje 4000 Kranj 5000 Nova Gorica 6000 Koper 7000 (unassigned) 8000 Novo mesto 9000 Murska Sobota
Like in Croatia ([Free_The_Postcode#HR HR]) postal codes in Slovenia are assigned to a post office, not to a particular geographic area, although an office has assigned places (city, villages...). Bigger companies (national television station, mobile operators, newspapers...) get their own 4-digit post code.
Post code finder and download: http://www.posta.si/Namizje.aspx?tabid=76
AT
nnnn
For the format, consult wikipedia: [4].
There is an up-to-date list available from the Austrian Post website that associates each postal code to (parts of) municipalities; it consists of 5 columns, giving the community, Bundesland (federal state), municipality, postal code, denomination of the post office. In order to use those data for OSM, the Austrian Post should probably be asked first if that's okay for them. As postal codes tend to be rearranged sometimes, a script checking for changes in that file might then be quite useful.
PL
nn-nnn
Like Croatia / Slovenia - assigned to the post office. In most cases first three digits identify city (nn-nxx). Consult wikipedia for more details: [5]
NO
nnnn
Postcode / area:
0100-1299 Oslo 1300-1999 South East region (Østfold county) 2000-2999 Central East region 3000-3999 Central South region (Vestfold, Telemark counties) 4000-4999 South (Agder, Rogaland counties, Stavanger, Haugesund) 5000-5999 West (Hordaland county, Bergen) 6000-6999 North west region (Ålesund, Molde) 7000-7999 Mid Central region (Trøndelag counties, Trondheim) 8000-8999 Low north (Nordland) 9000-9999 High north (Troms, Finnmark, Svalbard)
FI
nnnnn
Smaller numbers in the south, bigger in the north
There's a service for mapping between street / city and postal code at http://www.itella.fi/online-palvelut/tyokalutjalaskurit/postinumerohaku.html
ZA
nnnn
0000-2999 Northern Region (Gauteng, Mpumalanga, most of North West, Limpopo) 3000-4999 Eastern Region (Kwa Zulu Natal, eastern part of Eastern Cape) 5000-6699 Southern Region (Eastern Cape, eastern parts of Wetsern Cape) 6000-8299 Western Region (Western Cape (Cape Town and West Coast), Northern Cape) 8300-9999 Central Region (Northern Cape and Free State) (excluding 9000-9299, formerly South West Africa)
Wikipedia:List of postal codes in South Africa
Legal
As stated on the website itself. PLEASE ONLY ENTER DATA YOU YOURSELF HAVE COLLECTED WITH A GPS OR DERIVED FROM COPYRIGHT-FREE DATA. Other data may be copyrighted!
Alongside the data links the website also mentions the words 'public domain'.
See Talk:Free The Postcode#Legal for more detail (discussions)
FTP Stats
For Freethepostcode stats and graphs, look at this page: FTP_stat
Links
- http://opengeodb.sourceforge.net/
- http://developer.skolelinux.no/~pere/gis/openstreetmap/pcode-location.txt
- http://www.kirit.com/Free the Postcode — mirror of UK database available in other formats
other data
FTP will be upgraded to take other postcodes and also train stations. Until then, I'm dumping the data here:

