It’s common to have the postcode of an address and need to plot this on a map. In this post I show you two options for how to convert postcode coordinates using an online tool or data available for free online.
Option 1. Use an Online Conversion Tool
Often the easiest way to convert postcode coordinates is to use an online tool like this one. You can upload your address data at it will give you OS grid reference coordinates, eastings and northings, as well as latitude and longitude.
The tool also gives you the option to view your points in an interactive map:
Option 2. Do It Yourself
It sometimes makes more sense for you to convert postcode coordinates yourself. In this case I would recommend downloading the most recent ONS Postcode Directory which contains a list of all postcodes and their corresponding coordinates.
Once you have this then it is just a case of matching your list of postcodes with the correct ones in the ONS directory. To do this in SQL, you would want something like:
SELECT T1.Name, T2.Lat, T2.Long FROM my_data as T1, ons_directory as T2 WHERE REPLACE(T1.Location, ' ', '') = REPLACE(T2.pcd, ' ', '')
which joins the two tables together on the postcode. And gives the latitude and longitude for the postcodes in the “my_data” table. Once you have the latitude and longitude from the ONS directory you can convert to other coordinate systems as needed.
Which ever way you do this you will probably need a line like:
REPLACE(T1.Location, ' ', '') = REPLACE(T2.pcd, ' ', '')
to deal with postcodes being written with different amounts of whitespace.