databases icon
5th
Oct 11

Free UK Postcode Database – Towns & Counties

Posted Wednesday 5th October 2011
Towns aren’t accurate
The towns aren’t accurate within the database as some postcodes cover more then one area. This will change in the next major release.
You may (or may not) know that post codes in the UK aren’t free. The Royal Mail makes quite a fair sum (£75,000 for one type of corporate license, ouch!). It’s PAF (Postcode Address File) contains over 28 million addresses and I had previous experience with it before on a ticket agencies system. It’s not completely accurate but it’s the best thing available.

Skip to download

When you come across websites that fill in your address after entering a postcode you can bet they’re using the Royal Mails PAF. But what if you are looking for something less specific such as associating a town or county with a postcode? There are free tools and databases out there but I couldn’t find anything specific enough for my needs.

The data set provided contains 2,848 postcodes (postal out-codes) covering England, Scotland, Wales, Northern Ireland, Guernsey, Jersey and the Isle of Man. This includes eastings, northings, latitude, longitude, town, region, country code and country name data. The database is available in the following open formats; SQL (MySQL), SL3 (SQLite), JSON, XML, LibreOffice ODS and CSV.

Download Here

I’ve extended on the ezpy Free UK postcode data file to include the region and county for each postcode (along with the longitude and latitude provided by ezpy). It includes 2822 postcodes and a postcode such as “EX32″ will contain the town “Barnstaple” and the county “Devon”.

The download contains an SQL and CVS file which you can use freely.

Update 0.5 – Jun 10th 2011

This release includes country codes and names using the ISO 3166-2:GB standard codes for the UK and ISO 3166-1 for the Isle of Man, Guernsey and Jersey.

Update 0.4 – Jun 10th 2011

This update improves the accuracy of data within the existing database prior to plans of releasing a new database based on the governments Code Point Open dataset.

The data contained in this update is quite a drastic change for the reason that some towns are very specific (for example “Aberdeen Airport”) due to longitude and latitude being used to determine the address as opposed to the actual postcode itself. I decided to go down this route as some postcodes cover more then one major area. For this reason the county column will always be more accurate then the “town”. The next planned database uses fully formed postcodes so this won’t be an issue.

  • Includes csv, SQLite sl3, LibreOffice ods, MySQL sql and XML files.
  • Latitude and Longitude has a higher precision to 5 decimal places
  • Counties are more specific based on postal addresses and less ceremonial.

Update 0.3 – Oct 8th 2010

This update contains 27 additional postcode entries thanks to Dennis Milns. The new entries are CB21-CB25, GY1-GY9, IM1-IM9, JE1-JE5. I’ve also included the Northing and Easting for these postcodes. Thanks Dennis!

  • Includes a csv, Microsft Excel csv, MySQL sql and LibreOffice ods
  • Removed some odd spaces ‘ ‘ appearing for some county and town names

Update 0.2 – May 14th 2010

The postcode database has been updated improving and fixing upon some of the issues discussed. In some cases towns and cities don’t use a county so this has mainly been replaced with the town/cities region or ceremonial county. For example Birmingham (city) now has West Midlands (county).

  • Now includes a csv, Microsft Excel csv, MySQL sql and Open Office ods
  • Corrected the Longitude/Latitude columns in the SQL file. The values were correct but the data type wasn’t (doh)
  • Improved the duplicate “town/county” issue

Download Files

Date Version Archive Filesize Download
5th October 2011 0.5 bzip2 396.1 KB dg-postcode_db-0.5.tar.bz2
5th October 2011 0.5 zip 491.1 KB dg-postcode_db-0.5.zip

Older Versions

Date Version Archive Filesize Download
10th June 2011 0.4 bzip2 321.2 KB dg-postcode_db-0.4.tar.bz2
10th June 2011 0.4 zip 361.6 KB dg-postcode_db-0.4.zip
8th October 2010 0.3 gzip 253.5 KB dg-postcode_db-0.3.tar.gz
8th October 2010 0.3 zip 239.9 KB dg-postcode_db-0.3.zip
14th May 2010 0.2 bzip2 199.0 KB dg-postcode_db-0.2.tar.bz2
14th May 2010 0.2 zip 233.0 KB dg-postcode_db-0.2.zip

Bookmark or share this page:

SociBook del.icio.us Digg Facebook Google Yahoo Buzz StumbleUpon

MSN Contact: contact [at] danielgibbs.net



84 Comments

  1. iplanweb 9 September 2009 10:11 pm

    Great Job!! really helpful and handy for the kind of work I am doing.

  2. John 6 October 2009 12:25 am

    Unfortunately the UK towns/counties dbase seems to have quite a number of innacuracies. e.g a number of “counties” are in fact just the POST TOWN duplicated, which rather spoils it all.

    Regards,
    John

  3. Gibbs 6 October 2009 9:15 am

    Hi John and thanks for the feedback. Unfortunately I haven’t had much time to improve on the accuracy but for my specific task I needed the postal town. Anybody wanting to make additions and improve upon it are free to do so. When I have the time I’ll try and work on it and maybe even house it somewhere on the new (not live) site.

    Cheers

  4. AMF 15 December 2009 12:39 am

    Thank you. This is just what I was looking for, to validate delivery addresses. The SQL script will save me a minute or two. I am surprised that it is not more readily available. In some places there are two or more posttowns for one outward postcode. Do you plan to include all of these and the remaining counties at some stage?

  5. Gibbs 15 December 2009 10:12 am

    Hey AMF. This is far from perfect I completely agree on that. I do plan on an update but it’s going to take time.

    I’ve generated a massive list of over 3 million postcodes and have validated if they exist of not. The difficult part starts after then. It will have more specific regional information though instead of generalising things under the main post town.

  6. RussH 30 December 2009 9:22 pm

    this is a great start – and whilst don’t want to look a gift horse in the mouth, am really looking forward to your updated version!
    I wondered however if this news story give you any extra information to use in order to validate your data?
    http://news.bbc.co.uk/1/hi/technology/8402327.stm

  7. arif 7 January 2010 9:30 pm

    Looking forward to your finished goods.

    will be an excellent belated xmas present.

    the ezpy is a fabuolous database/resource – i was just thinking of adding towns to it myself… you’ve beaten me to it !

    .. but plz move up a gear and finish it. Just work on the epzy 2822 records.

    for full blown postcode database http://www.linuxbox.co.uk has something on offer. 3-million will take you far too long and will still be way short of the 28-million postcode royal mail database.

    let us know when your done with the 2822-records.

    thanks and good luck.

  8. Ollie Treend 11 May 2010 5:23 pm

    You, my friend, are a God!
    Thank you very much for this excellent resource!

    Unfortunately your lat+long points were a little mangled… they’re all to 1 significant figure??
    But that’s not a problem… I simply used the lat long values from ezpy’s list, and your town & county names.

    Your new list does sound rather impressive, but this will do for the time being!

    Thanks again

    Ollie

  9. Dan Peters 13 May 2010 5:36 pm

    Hi,

    Wanted to give you a big thanks for this free database and look forward to your update for it coming. =)

    Dan

  10. Gibbs 14 May 2010 7:35 pm

    I’ve finally got around to updating this. There’s been some fixes and improvements that were mentioned (thanks for all the feedback by the way).

    Grab it above the comments section or at http://www.danielgibbs.net/files/postcodes/.

  11. Dan Peters 19 May 2010 12:45 pm

    Thank you for the update Gibbs, going to try using this today!

  12. Jonney 29 June 2010 9:13 pm

    Excellent resource. just what i was looking for. You have saved me a lot of time.

  13. George Edwards 2 August 2010 1:36 pm

    Thank you for releasing this file! Transparency prevails!

    Cheers

  14. Greenman 12 August 2010 3:09 pm

    Hi I am looking for something a bit different I am looking for a database of postcodes down to sector level ( G53 6)
    and a count of the number of businesses and households in the postcode sector. I thought about going through PAF but it would be really expensive for what I want.

  15. Gibbs 13 August 2010 10:14 am

    Hi Greenman,

    Apparently the government is releasing postcode data sometime this year. I haven’t heard anything about that recently but we’ll have to wait and see. Until then it’s very difficult (and time consuming) to compile a list of all postcodes and the relevant information.

  16. Chris Lomax 18 August 2010 11:05 pm

    Honestly, amazing. Been looking for this everywhere!

  17. scott 19 August 2010 9:02 pm

    Hi there

    This is excellent and probably exactly what i am looking for. Although being a novice web designer i wondered if this is possible to have a system whereby someone types in there post code and it takes them to a specific page (which obviously relates to the town) i.e someone types AB21 or AB12 and they are directed to the Aberdeen page.

    i dont know how i would relate search field on website to the csv file and subsequently to pages per town

  18. Dennis Milns 18 September 2010 11:34 pm

    I have looked at you data and it fits exactly what I want – However there seem to be a few missing Postcodes areas.
    I can send you my version if you want – Thanks Dennis

  19. Gibbs 19 September 2010 1:38 pm

    Hi Dennis. Please do :) . You can email me at: contact[at]danielgibbs.net

    Thanks

  20. Gibbs 8 October 2010 1:06 am

    Updated with postcodes contributed by Dennis Milns. I also aim to get PHP, Python and possibly other examples up in the near future.

  21. mark 16 October 2010 11:09 am

    Hi,

    Just to let you know some of teh counties are incorrect, these are the old ones. For example Bolton and Manchester or now in Greater Manchester and not lancashire. Cardiff and all the other welsh towns have the old counties. Cardiff is now in the county of Cardiff and not Glamorgan.

    Thanks

  22. Gibbs 16 October 2010 11:42 am

    Thanks mark. I will be looking into improving the countiea again for the next release

  23. ausipad 31 October 2010 2:24 am

    Wow, this is exactly what i have been looking for for so long. Great job mate!

  24. My Shadow Self 1 November 2010 11:31 am

    This rocks and is exactly what I’ve been looking for.

    The Post Office’s list is way beyond the means of most eductional institutions, but you’ve made a seemingly impossible project absolutely possible.

    Thank you very much

  25. My Shadow Self 1 November 2010 11:35 am

    Oh, one thing I’ve noticed with the package. You’re distributing this as GNU gpl, which is brilliant, but you need to include a copy of the licence in the distribution. You can find it here: http://www.gnu.org/licenses/gpl.txt

    Thanks again

  26. Gibbs 1 November 2010 11:55 am

    I thought I put a link to the license in the readme… Will get it updated when I’ve done some fixes to the DB.

    There’s a lot that can be done with the database but it was a good start for what I needed it for.

    Cheers for that.

  27. My Shadow Self 1 November 2010 11:59 am

    No worries Gibbs.
    There is a link, but the GNU advises to keep a copy in the distribution incase “URLs become obsolete”

    Just getting to grips with what I can do with this data mate, so very grateful.

  28. Karl Norman 23 November 2010 4:40 pm

    This list is very inaccurate. Most of the DN towns are incorrect as are the PE districts.

    Im currently mashing my own data from os and converting and updating Eastings and Northings to WSG84 and also introducing counties, towns and locallities.

    I have been playing with a postcode boundings from the available free data and am returning a suprising set of results by looking up steetnames from the gazeteer also. It will never be as acurate s the PAF file but for free im returning just 2 acurate street names per postcode. The data in these files is not anywhere near acurate enough for returning timesaving result sets

  29. Gibbs 23 November 2010 5:03 pm

    Hi Karl,

    Thanks for the feedback. A lot of the data is simply expanded on from the Ezpy database as there was limited data out there when I need it (that I could use legally). I’d definitely be interested in seeing anything you come up with though.

    I’ve only ever used the towns in this so I can’t vouch for the accuracy of the other data. I know that there is a lot of room for improvement on the counties, easting and northing info.

    At the moment I don’t have the time, need or interest to maintain this properly but I do want to revisit it sometime in the future. This is “out there” though for people to take and run with however they want.

    Cheers

  30. Rob W 29 November 2010 5:53 pm

    Hi Daniel,

    Great work with this! However, Bristol is in either ‘Avon’ or ‘South Gloucester’, depending on council area. No BS post codes come under Gloucester at present…

    Cheers,

    Rob

  31. JJ 16 January 2011 12:15 am

    Just what I needed. Many thanks for making this available, much appreciated :-)

  32. Steve 29 March 2011 12:21 pm

    FYI
    http://data.gov.uk/dataset/os-code-point-open

    1.7 million records just downloading it to see usefulness

  33. Ian 30 March 2011 8:16 pm

    Very nice work lads! Cant believe royalmail is still continuing with their closed data policy :(

    Keep up the good work! 10/10 :D

  34. Tommy Conlon 18 April 2011 11:00 am

    Many thanks Daniel.

    re. towns – this looks like a useful resource:

    http://www.hesa.ac.uk/dox/datacoll/C10018/Postcodes.pdf
    Tom

  35. Kevin 27 April 2011 12:04 pm

    Just a small comment to say that middlesex isn’t a county anymore… I can’t seem to find a more up-to-date list…

    Other than that this compliation is great :) thanks very much!

  36. Aaron Johnson 29 May 2011 6:53 pm

    Well done, this is really useful data.

    I too have downloaded the full postcode database from data.gov.uk, but the town and county is not in that dataset.

    Thank you,

    Aaron

  37. Mike Gillespie 7 June 2011 6:30 pm

    Hi, I love the idea but the problem is that it is not right fella… for example BH1 is Bournmouth, the last time I looked that was in Dorset not Hampshire…. I think as a base resouce your doing a great job but its too hit and miss to become a project or resource that can be relied upon.

    Happy to talk or help..
    Mike

  38. Gibbs 10 June 2011 9:05 am

    I am revisiting this using the Code-Point Open dataset provided by the government. I’ve approached it differently to make it more accurate as trying to determine “counties” is too fallible. Instead it will just use the “postal region” that addresses using the postcode have. It should be up within the month.

  39. Dennis Milns 10 June 2011 9:58 am

    Please try to preserve the counties as I am developing an application which uses the county as an optional search criterion.

  40. Gibbs 10 June 2011 10:12 am

    The “postal regions” will in effect be counties but they will be more technically correct.

    For example Swadlincote will have a postal region of “Derbyshire” whereas somewhere like Chellaston will just be “Derby” as that’s how their postal addresses are formed.

  41. Gibbs 10 June 2011 6:56 pm

    Updated to improve the accuracy of counties. The towns within the DB have also changed (read post) as well as a couple of additional formats being provided.

  42. Ian Weatherhogg 13 June 2011 6:23 pm

    Very useful thanks.
    The SQL inserts into table ‘finished’ which I don’t think is correct.

    I’d love to see a new column ‘Region’, e.g. East Midlands, West Midlands, etc

  43. Gibbs 13 June 2011 7:21 pm

    Thanks for pointing out the SQL inserts going to the wrong table Ian, should be fixed now.

    I will look into adding regions. The only problem I can think of off the top my head is that Scotland no longer has regions (they have council subdivisions AFAIK).

  44. henderson101 14 June 2011 9:52 am

    I’ve used this to fix a hole (and long term bug bear) in some data we use to do address lookups. I’m really only interested in counties. The “Postal region” used for the county isn’t always correct though. Example: Portsmouth, is in Hampshire. To correctly address a letter to a PO1 – PO6 address, Hants or Hampshire should be the county… you have “Portsmouth”. This isn’t right. Portsmouth is a City. I didn’t look in to this any further, as I was using postcodes I knew off the top of my head… but anything PO7-PO9 seems to correctly list Hampshire.

  45. Chris Morse 21 June 2011 6:06 pm

    Hi Dan,

    Thanks for all your work on this.

    Forgive me if I’m missing something glaringly obvious but I can’t seem to find out where I would download the latest update … the only link I can see on this page is in the bit of text at the top when you say “I’ve extended on the ezpy Free UK postcode data file to include the region …” but when you navigate to that page, the only file to download is the original zip file.

    Can you reply to this message and include the link to the latest version of the download, or send me a zip file to my email address?

    Cheers,

    Chris

  46. Gibbs 21 June 2011 6:59 pm

    Hi Chris,

    The links are at the bottom above the comments area.

    Version 0.4 (ZIP)
    Version 0.3 (ZIP)

  47. Chris Morse 22 June 2011 1:05 pm

    Hi Dan,

    Thanks again. I should have looked a little closer.

    Here are some postcodes which I think you may be missing. Sorry, have only checked the first few.

    AB24
    BD97
    BD98
    BN50
    BN51
    BN52
    BN99
    BS98
    CF30
    CH28
    CH30
    CH31
    CH34
    CM77
    CM92
    CM98
    DH97
    DH98
    EC1P
    EC2P
    EC4P
    EH91
    EH95
    FY0
    G70
    G75
    JE5
    KY99
    L67
    L68
    L71
    L72
    L73
    L74
    LE19
    LE21
    LE41
    LE94
    LS98
    LS99
    M50
    N1C
    NE82
    NE83
    NE85
    NE98
    NR7
    NW1W
    PA80
    PH37
    PR0
    S96
    S98
    ST55
    SW95
    YO90

    Can you possibly send me the data in CSV format for these postcodes or send me the calculation you use for converting longitude for latitude.

    Also, here are some entries for which the longitude and latitude were the same, although the postcode was different.

    GY3
    GY4
    GY6
    GY7
    GY8

    Cheers,

    Chris

  48. Chris Morse 22 June 2011 1:06 pm

    One more to the “missing” list is S97

  49. Gibbs 22 June 2011 2:08 pm

    Hi Chris. A CSV file is provided in the downloads. Under the tools directory is the longitude / latitude script to do the conversions using the mapnik toolkit.

    I will get around to adding the missing postcodes eventually but I’m working on a new database that uses fully formed postcodes (provided by the Code-Point Open datasets) so it won’t happen immediately.

    Also thanks for pointing out the Gurnsey long/lat problem. Will get that fixed when I check and add the postcodes you provided.

    Cheers

  50. owen 15 July 2011 12:34 am

    Hi

    I have a list of the 2880 GB postcodes with their lat/lng if that’s of any use. It has all the GB omissions that Chris highlighted. Can be provided to postcode sector level if required. Data is from the latest Code-Point Open Dataset. The csv provides lat/lng to the WGS84 standard (ie as used by GPS. It does not provide region area etc but i’m sure you can merge that from the datasets already provided.

    Cheers

  51. Gibbs 15 July 2011 9:32 am

    That would be great Owen. Cheers

  52. Jason Michaelides 25 July 2011 9:41 am

    Fantastic resource – thank you!

    Do you by any chance have Country to add to this list? I need to break up UK into Countries and I have the postcodes.

    Cheers,

    Jason

  53. edge of the web - warwick 2 August 2011 2:43 pm

    You are a legend…thanks for doing this

  54. andy1927 5 August 2011 7:43 pm

    Legend. Kudos!

  55. Alex 26 August 2011 6:33 pm

    The download links no longer work (account suspended)

  56. Gibbs 27 August 2011 7:19 pm

    Cheers for the heads up Alex.

    I will get it moved in the next day or so. The server its on (cheap hosting) has been hacked so I’ve suspended the account on there until I can get everything moved.

  57. Gibbs 27 August 2011 8:23 pm

    Files have been moved and should be working.

  58. Simon Hill 31 August 2011 7:03 pm

    Hi,

    Many thanks for your hard work with this. We have used your postcodes on a number of our projects and to develop more accurate tools. Thanks Again.

    Simon

  59. Chris 16 September 2011 2:25 pm

    Many thanks… Chris

  60. Ben 3 October 2011 12:38 pm

    Great work thanks for this… how about including the country as well (England, Wales, Scotland, Northern Island)?

  61. Simon 5 October 2011 6:33 pm

    Data looks good. Thanks for your hard-work and making this public!

  62. Gibbs 5 October 2011 9:40 pm

  63. Bradley Kieser 13 October 2011 11:00 pm

    Thank you for the great work here. I have converted this into a properly normalised (3rd Normal Form) Postgresql set of tables. There are:
    – uk_postcode_country_codes
    – uk_postcode_regions
    – uk_postcode_towns

    and then the main table, uk_postcodes which references them.

    country_id, country_code_id, region_id and town_id in this table refer to each of the above reference tables respectively.

    The file is in pg_dump format (easily ported to other DBMSes). Replace YourSchemaOwner to the owner of the schema you are loading into (if public then this is usually the database owner)

    Download from here: http://www.sms-speedway.com/uk_postcodes_05.pgdump.bz2

  64. Gibbs 18 October 2011 6:15 pm

    Many thanks for that Bradley, I haven’t touched on Postgres in a long time so the addition is welcome! Good stuff.

  65. Tom Conlon 22 October 2011 12:25 pm

    Hi all,

    *** A week left before Open Data consultation closes ***

    Can you go to http://data.gov.uk/opendataconsultation/questions#comment-7139
    and make your voice heard too.

    Thanks,
    Tom

  66. Rob James 31 October 2011 4:21 pm

    Hi, this has been invaluable in my attempts to parse data from a text field containing UK addresses into separate fields for each line of the address. I see above that you’ve got plans to include accurate mapping of towns from postcodes in the next major release which will be tremendously helpful. Any idea when this might be coming out?

    Cheers Rob.

  67. Leigh 9 November 2011 4:41 pm

    many thanks for this! well done!!

  68. Bradley Kieser 10 November 2011 5:10 pm

    Dan, it’s a pleasure and thank you for this project and all the work done on it.

    I’ll keep posting updates here as an when you release new versions.

  69. Dean Harrison 18 November 2011 4:19 am

    Hi Dan. Thank you for taking the time and effort to put this together and I really hope you continue with it. I have noticed a large number of inconsistencies where you give the town name as a ward. E13 you give the town as East Ham which is a London borough ward. There are 9 borough wards in E13 so why East Ham? I was researching this and stumbled across this link http://postcodepal.com/?page=matrix which breaks everything down nicely. Perhaps you could use it as a reference point when you put together the next version? Please don’t give up on the project. It will be such an invaluable resource once completed.

    All the best.
    Dean

  70. Dean Harrison 19 November 2011 6:06 pm

    To follow up my last post is would appear that the site I made reference to has a xml and json api.

    http://api.postcodepal.com/E138HR.xml
    http://api.postcodepal.com/E138HR.json

    Unfortunately it only accepts full post codes. Maybe it will help someone?

    Regards.
    Dean

  71. Gibbs 25 November 2011 9:03 pm

    Thanks Dean. That service isn’t “free” though so I wouldn’t want to base any data on it. I will add it for random accuracy tests though. Cheers

  72. Dean Harrison 26 November 2011 12:35 am

    You are most welcome Dan. I contacted the admin of that site and got this link off them today.

    http://postcodepal.com/?page=database-generator

    The database links are

    http://postcodepal.com/dbgen/postcode_districts.zip
    http://postcodepal.com/dbgen/postcode_sectors.zip

    I’m not interested in paying for a full database (can’t afford it) nor do I have the space to host it. The above is more than what I needed. Might save you some time and these ones are free :) I haven’t tested them for accuracy yet. Hopefully get some time this weekend.

    All the best,
    Dean

  73. Chris 2 December 2011 2:27 am

    Another valuable source would be the UK government database of all 1,841,177 post codes together with precise geographic coordinates and other information, 8 Jul 2009.

    This was discovered on wiki leaks and can be downloaded from the famous bit torrent site, infact the link is on wikilinks, it contains full postcodes etc, except for the damn street names, counties and towns.

    It would be great if someone could put this together with the missing info, bewarned its a massive file, open in access etc as excel wont load all the entries!

  74. Chris 2 December 2011 2:27 am

  75. Charles 3 December 2011 1:33 am

    Firstly, thanks for the work you’ve out into this Dan, it’s been very useful.

    I’ve found that the locations in the PostcodePal files above are very suspect. They don’t match up with the Code-Point Open data very well, and some just look plain wrong.

    As a quick example look at the very last district, ZE3. Code-Point puts all ZE3 postcodes (there are only 12 of them) on the southern tip of the island, but PostcodePal puts the ZE3 centroid in the middle of the island. I have no idea how they calculated that.

    The town, district, county, and region data does seem to be accurate though.

  76. Dean Harrison 7 December 2011 12:38 am

    Hi all, was just about to come back and post what Charles above me had said. The centroids were well out. I contacted them about it and apparently they were not clearing the previous district or sector from their calculations. This has now been fixed or so they say. Will check it properly when I get some time but first glances do look ok. Not wanting to go off-topic but does anybody know a good source for french postcode centroids?

    Cheers!

  77. Charles 10 December 2011 9:34 pm

    I have downloaded that data again, and yes, the centroid calculations now look more correct…but…

    Blindly calculating district/sector centroids from all raw postcode locations doesn’t work very well in many cases.

    Example;

    “B1″,”Birmingham”,”403511″,”276448″,”52.385675″,”-1.948398″

    If you plot this location on Google maps you can see that it is miles away from Birmingham. The reason for this is easily seen if you look at the raw Code-Point data. There are many postcodes within B1 with the location 375350,164483 (51.378366,-2.354215) – which is in the middle of Bath. (Although strangely, if you type one of these postcodes into Google maps, e.g. B1 3PF, it does show it in Birmingham…not sure where Google are getting this from).

    Now, I don’t have access to the full Code-Point dataset so this is speculation, but seeing as all these postcodes share EXACTLY the same location I would guess that they are PO Box codes (the Code-Point Open data doesn’t include the PO Box indicator flag). In my opinion these codes should not be mixed with “real” codes in centroid calculations, because they are useless for just about any practical location usage scenario. If you want to know whereabouts of the B1 district then generally you don’t care about PO Box addresses in Bath.

    So lacking PO Box indicators, what I do when processing the Code-Point Open data is to just ignore any non-unique locations. This works well in most cases, my result for B1 centroid is 406194,286859 (52.479252,-1.908789), which is within 100m of what Dan has.

    Hope that helps :)

  78. Dean Harrison 12 December 2011 8:10 am

    Thanks Charles. That is very interesting information and a very valid point. I’m going to see what they have to say about that. I think it would be great if they could make the same adjustment. I’ll let you know how that goes. I don’t know where Google are getting the coordinates for B1 3PF from but I’m assuming it’s from their database of business listings? I’m guessing that the business locations tied to that po box are all in Birmingham? Perhaps? My brain is pickled. Way too early for me I’m afraid.

  79. Aycan 13 December 2011 9:07 pm

    Hello guys i need full uk database file in SQL, i am ready to buy it can be older is well no proble..

    If you would like to sell it please contact me on: firma(at)aycan.co.uk

    Thanxs

  80. Dean Harrison 14 December 2011 10:21 pm

    Hi guys. It would seem Charles did make a credible point with the po boxes. I got a response back today. I can’t be bothered to type it all out so I will just copy it here.

    ——————————————–
    Dear Mr Harrison,

    Thank you once again for contacting us with regards to our free centroid databases. We have carefully considered all of your points. In order to calculate a true centroid we have to equate for every geographical coordinate, regardless of whether it is associated with a po box number or a residential or commercial property. Non-unique locations are not always associated with po box numbers. We have taken a look at the B1 district area and were very surprised to find that the centroid given had so much weight pulling it towards Bath. It does not match our own calculations. After analysing the code we use to generate these databases online, we realised that the reason for the discrepancy was because of far too much duplicate weighting factors. In other words we had been feeding in duplicate coordinates into our equations and that resulted in what we refer to as biased or unfair weight. We must apologies for this. The problem was due to issues porting our original delphi code over to php for use online. This has now been addressed. All calculations are now based on unique coordinates, which is as they should be. A single coordinate that is located a great distance away from the majority of district or sector locations will only ever have a very negligible influence concerning the location of the true centroid coordinate. This is another reason why ignoring non-unique locations altogether would be a very bad idea, as they do not actually have much sway over the position of the final centroid, when you consider the weighting factor in its entirety. Also, this may or may not be of interest to you, but we now offer the same databases with average centroid calculations. This works by taking the average coordinate as the centroid coordinate. Both databases can be generated and downloaded from our website here: http://www.postcodepal.com/?page=database-generator.

    If you have any further queries then please do not hesitate to contact us.

    Yours Sincerely,
    Mark Johnston
    ——————————————–

    Not quite sure what advantage an average centroid has over a true centroid?

    Dean

  81. Neil 18 January 2012 7:17 pm

    Great job Dan, thanks for this!

    Do you or anyone else know of any resources that give the eastings/northings for Postal Towns? (So for example, when I search on Google Maps for Birmingham, Google takes me to the centre of Birmingham. I assume they have some way of working out the coordinates of the centre of a town?)

    Is there a free resource that lists the central eastings/northings coordinates of a town?)

  82. Tim 24 January 2012 2:03 pm

    Hi, many thanks for this – very useful for me!
    I’ve just noticed that Flitshire is listed as being in England, but I believe it should be Wales.

  83. Jon 24 January 2012 8:21 pm

    Hi,

    This seems to be a great resource so congratulations on doing such a great job.

    I was hoping someone could shed some light on a requirement i have. Ok i have a list of lets say 300 houses all over the uk which i have postcodes for. What i need to do is allow a user to enter there postcode and then display the houses within a certain radius ie 10,20,30 miles etc. This resource i dont think does not narrow things down enough, if it does please say so, if not please does anybody know where i can get hold of it, PAF is not an option obviously. I will be doing this in asp.net if anyone can help me.

    Thanks Jonathan

  84. Jonathan 25 January 2012 5:07 pm

    Hi,

    Great job what a fantastic resource. One quick question i have is can i use this data in order to work out radius positions form a give postcode. ie if i had 200 property postcodes around the uk and then i get a user to enter theres i need to say get all properties within 30/40/50 miles etc of that postcode. If it can can anybody advise how or even if this data does not go down to the next level needed is there any where i can get this data. Obviosuly PAF is not an option.

    Thanks all in advance

TrackBack URL

Leave a comment