New Zealand Postcode Database (V2)
I’ve done a bit of work on the database, added a bit of information and corrected mistakes.
Thanks to Owen and others for help with the data.
If you find this data useful, please donate.
What’s new in V2
- More accurate
- Added GPS co-ordinates
- Added PO Boxes and Private Bags
- Added Rural postcodes
- Removed regions (as some datasources labeled a city/town as one region and others differed.)
I’ve also taken the opportunity to include CSV and MSSQL formats, as well as MySQL.
History
I originally created the database as I needed street and suburb data for a project I was doing. No one else was stupid enough to spend that much time on it, so I took it on. NZ Post still has their PAF data, but are unlikely to release a free database of the postcodes.
Original Post
More info on NZ Addresses
Downloads
MySQL
nzpostcodes_v2.sql.gz (655KB)
nzpostcodes_v2.sql.bz2 (445KB)
CSV
nzpostcodes_v2.csv.zip (1.07MB)
All efforts have been made to ensure that there are no errors, but there are no guarantees, if you need 100% accurate data please buy NZ Post’s PAF data.
[UPDATE 20/04/08]
As a few people have pointed out, there was no suburb data in the MySQL database version of the postcode database. This has now been fixed. Sorry about the problems and how long it’s taken me to get around to fixing it.
@alex
Regions were very subjective depending on what dataset you look at. I.e. Taupo is sometimes in Waikato, sometimes in Bay of Plenty. If someone can find a list of cities and regions then I can match it up.
@Richard
Thanks for the comment, but this is what I did with v1. It was horribly inaccurate and took me ages to fix up import problems as PDF->text didn’t work well.
The database I have now has a lot more information including long/lat coords for streets, which cannot be parsed easily from the PDF.
@Chris
This is the break down that I get from the database:
359 – urban
692 – rural
687 – PO Box
1738 postcodes
@Peter
If you use the rural table from the MySQL db then you’ll find that 3288 is RD8 Hamilton. CSV file only has urban street addresses.
@Brett
Thanks for this, I will write a script to fix these up, they should be pretty easy to spot. I’ll try and get an update this weekend if I get time.
All great work. NZ post don’t make it easy to extract the data. The PDFs ( from NZ post) can be by Region but you have not added it as a field. This would be the gold, as most reporting is done by region. Are you able to add this field to the data?
This is fantastic, and I really appreciate your efforts. The postcodes are one peice of the puzzle for a project I am working on, the other being SNZ mesh blocks. Are you able, or do you know anywhere, where these two have been aligned?
Hey, how current is this postcode list?
Just dropping a note of thanks, awesome to see helpful projects like this, keep up the good work.
Thanks for your efforts, appreciate it
This is just what I was hoping NZPost would provide when they introduced the new system. Since then I have been putting off the evil day when I would have to do it myself.
My interest is I’ve set up databases for a number of not-for-profit groups to which I belong, with a button to look up the Postal code and insert it after they have typed in the address of a member.
To use this data in the same way, would I need to pay and to whom and what about NZ Post copyright. I don’t want any suprises down the track. So I’m asking before starting what will still be quite a lot of work 🙂
Thanks very much for the DB. It really helped a lot!!!!!!!!!!!!
You are a legend mate!
Is there a way to determine the region by postcode e.g starting with a particular digit?
You are a star. Saved me a heap of time and money
Thanks heaps. Do you have a phone number db to by any chance?
You. Are. A. God.
Thank you so much!
To everyone who wants to associate suburbs with region (no matter the accuracy) do the following;
1) Import the V1 version of the postcode database
2) Import the V2 version of the postcode database
3) Add a column to the suburbs table from the v2 database called regionid INT(11)
4) Run the following SQL (note I appended “location_” to the start of all my V2 tables, and renamed the V1 table postcodes_v1):
UPDATE location_suburbs, location_regions, postcodes_v1 SET location_suburbs.regionid = location_regions.regionid WHERE location_suburbs.suburb = postcodes_v1.suburb AND postcodes_v1.region = location_regions.regionid
Hope this helps… all I’m looking for is a nice way to let people who register on a site pick a region and suburb!
Or you can use this to extract the postcode from the NZ Post PDF
http://www.srmiller.net/nzpostcode/nzpostcode2csv.zip
I would love a NZ postcode csv file with simply the postcode and the region.
If anyone has one, can you please let me know how I get it.
Thanks
Thanks great job you have done
Legend! Thanks so much for putting this together
I’ve done a bit of playing and
A) converted it into Postgresql sql
B) converted the addrinfo column into a streetMin and streetMax column
if anyone wants it — the current streetMin and streetMax are in Postgres format, but its fairly trivial for me to turn them into CSV or mysql if the desire was there
Hi, I needed a list like this for my company, but I am donating to you out of my own pocket, purely from admiration and personal thanks.
@Scoro
Scoro: Any chance of a copy? Please send to [email protected]. Ta!
Woops, could I have it in csv?
Hi,
Does anybody have a csv file of NZ postcodes to regions that they could send me. Would be greatly appreciated. I tried looking at the link http://www.srmiller.net/nzpostcode/nzpostcode2csv.zip but it doesn’t seem to work anymore
You can look up and download NZ Postcodes (in the new format) with city and very precise latitude and longitude data.
from http://www.zippostalcodes.com/postcodes/nz/
Hi there could I also get a copy of the CSV please to [email protected]
Thanks
Hey thanks for doing such a great job with this!!
Here’s a query for combing all 3 tables in to one table:
INSERT INTO customer_nz_postcodes
( postcode, suburb, town, rural_d )
select postcode, suburb, area as town, null as rd FROM suburbs
UNION
select postcode, NULL as suburb, town, rd FROM rural
UNION
Select postcode, lobby as suburb, city as twon, null as rd FROM boxes
(tip: Disclaimer: I’m not from NZ, is it reasonable to generalize like this?)
IF YOU’RE TRYING TO SAVE AND OPEN THE CSV FILE AND GETING AN ERROR –
DELETE ‘.CSV’ OUT OF FILE NAME BEFORE SAVING.
SAVE AS – ‘nzpostcodes_v2.zip’
DON’T SAVE AS – ‘nzpostcodes_v2.csv.zip’
Given this appears to be the hub for NZ Post Code data 😉
A csv of the current Post Code Directories can be downloaded here http://dl.dropbox.com/u/3425612/NZPostCodes/NZPostcodesApril2012.xls
The source NZ Post pdfs show a creation date of May 2011 in the properties so I’m guessing the data Noodle is providing is somewhat dated/inaccurate/incomplete.
The link http://www.srmiller.net/nzpostcode/nzpostcode2csv.zip has been restored.
I’m looking for a list of old postcode and their ‘rough’ match to the new ones for a uni assignment. I’m trying to geocode postcodes, but have a list of 760 codes which don’t match NZ Posts current codes. Exact matches are not needed as I’m doing it to the TA (Territorial authority) area, so the old code for Hamilton – 2001 could match up to any of their 7 new codes 3200-3216 etc. Any help would be appreciated!
Has anyone successfully extracted the NZ Post *Auckland* postcode directory from .PDF?
I get an ‘Error converting PDF’ message when I try (despite renaming the file to the expected postcodedirectory_nomaps.pdf). No probs with Northland and NZ-wide directories though…
http://www.nzpost.co.nz/sites/default/files/uploads/shared/postcodedirectories/auckland-directory.pdf
Thanks for this extremely useful utility!
Hi
I have loaded your csv file into my website https://seek.estate but it is missing a lot of suburbs for NZ. When I try to add listings for NZ, many suburbs around Christchurch and the South Island are missing. Any chance of an update soon?
@Seek.estate
What suburbs are missing?
I think I have the same issue as seek.estate. I am just looking for a simple file linking postcode to it’s latitude and longitude. I couldn’t find one so we got the V2 list above. We also fond that many postcodes just didn’t exist. I’ll provide a few examples which I have verified on the NZ Post Postcode Finder.
1. Pito Street, Raurimu, RD1, Owhango comes up as postcode 3989, but this doesn’t exist in the V2 file.
2. Kaiwera Raod, Gore comes up as postcode 9772, but in V2 it’s 9710
3. Moore Road, Wakefield comes up as postcode 7095, but in [email protected] it’s 7025
I’ve been really pulling my hair out so would really appreciate any comments or advice.
This is over 7 years old now, so I’m sure it’s not very accurate now. I haven’t had the need for the data again so I haven’t bothered to update it. If there’s enough need/call for it then I’ll take another look.
@noodles
I actually need a file that had postcode, locality description and the latitude and longitude for the ‘middle’ of the postcode polygon. It’s seems I have that file now following heaps of emails to and from a contact in NZ Post. Given this has all taken me 3 months, if anyone needs such a file, is there some way they could access it through this site/page (when searching Google, this site still comes up high on the search list, so I think it might be useful)
@noodles
Thanks for the work!
Very much appreciated! Thanks
Just wanted to say this is brilliant. I will organise a donation for you from my current non-profit. Well done supplying this.
Hi Jay
I’ve matched your postcode file to my data and there are indeed a lot of post codes missing. Will you be updating the file at all? And if not can you suggest somewhere else I might get my hands on a current one.
Thanks heaps
Thanks!
There is no GPS data in the mysql tables? Anyway that could be added?
Hey @Noodles,
How current would you say your work here is? I’m not seeing a lot of recent dates at the top of the screen, but I don’t want to do any reinventing of the wheel if I’m playing around with postcodes to get the bits of data I want out of them. Just trying to gauge whether i’m best to grab your work (which looks good), or redo it myself from the Postcode directories? (Like a number of commenters, I’m most interested in REGIONS information which isn’t stored in the CSV version above.)
What’s your gauge on your database, still current, or best to rewrite?
Hi do you have an updated database please!
At this point the database is quite out of date. It hasn’t been updated since ~2008. I haven’t had the need for it, so I have tried to seek out new data.
Sorry, I don’t have an update for this.
Hello,
So no update means we now have to pay $1000 for the PAF 🙁 ? Anyone else know where we can get this free? I don’t mind paying once my new build site makes money but to save the cash while it is in development would be nice as I desperately need to invest that in other areas