UK Postcodes to GPS Coordinates

1,531 words

So you’re the proud owner of a GPS, and you’re travelling to an address for which you know the postcode. You want to enter the place you’re going as a waypoint. This sounds easy: just find a service that gives you the grid reference, and enter that into the GPS, but there are minor complications.

First the easy bit. Go to http://www.streetmap.co.uk and search for the postcode you want. For my example I’ll use Leamington Spa Town Hall, CV32 4AT.

This brings up a map. Verify that the arrow on the map points to somewhere that could sensibly be the place you want. Under the map, you’ll see something like:

(line breaks by me)

Use http://www.streetmap.co.uk/streetmap.dll?G2M?X=431837&Y=265809&
A=Y&Z=1 to link to this map.
Click here to convert/measure coordinates

Click on the “here”.

The next page contains all the information you need. For CV32 4AT I get:

OS X 431837
OS Y 265809
Nearest Post Code CV32 4AT
Lat (WGS84) N52:17:22 ( 52.289499 )
Long (WGS84) W1:32:05 ( -1.534662 )
LR SP318658
mX -170837
mY 6818814
M Actual : FFFD64AB_00680BFE
Street : FFFD65FC_00680AC4
Road : FFFD67F0_0067E990
Road64 : FFFE0C00_00678400
Road128: FFFE0C00_00678400

You can get straight to this page using the URL

… substituting the postcode you need. You can either omit the space from the postcode (”CV324AT”) or URL-encode it (”CV32%204AT”). Obviously if you do this, you miss out on the chance to validate the position on a map.

Some possibly needless discussion follows. Skip to the bottom for the quick summary.

In order, these are what the fields mean:

  • OS X: The X coordinate on the Ordnance Survey grid
  • OS Y: The Y coordinate on the Ordnance Survey grid
  • Nearest Post Code: The one you typed in, I’d hope
  • Lat (WGS84): The latitude using the WGS84 system, in
    degrees,minutes and seconds, then in decimal
  • Long (WGS84): The longitude using the WGS84 system, in
    degrees, minutes and seconds, then in decimal
    • WGS84 is a standard reference system (”datum”) for
      global coordinates
  • LR: Ordnance Survey Landranger Grid Reference
  • mX,mY,M: I really don’t know.

Now is the time to mention that my GPS is a Garmin, so if yours isn’t you’ll probably have to input waypoints in a different way to how I describe.

If your GPS is set to use WGS84 coordinates, then you can enter these into the “Mark” panel. However, if you’re in the UK it seems wisest to use the OS units (so you can use the GPS in conjunction with an OS map), so this the method I describe.

If you haven’t already done so, ensure you’re using OS units with Main Menu -> Setup -> Units. Make sure the position format is “British Grid” and the map datum is “Ord Srvy GB”. Take the opportunity to select your distance/speed unit: “statute” if you want miles, “metric” if you want kilometres. I don’t mind which you choose.

Now we can create a new waypoint with Main Menu -> Mark.

In the location field, then we can simply type in the grid reference from the Streetmap “LR” field, right? This is where the slight complication comes in. Set up the way we’ve done it, the location field has three sub-fields “– —– —–”, yet our Landranger grid reference is two letters and six digits.

The reason for this is that a standard Landranger grid reference gives the coordinate to within 100 metres, but the GPS allows you to specify the coordinate to within 1 metre — and furthermore Streetmap’s coordinates from postcodes are given to within a metre.

There is a full discussion of the Landranger grid reference system here. In brief, however, the first two characters are a pair of letters indicating the “sheet”, characters 3,4,5 are the 10km, 1km, 100m Eastings respectively, and characters 6,7,8 are the 10km, 1km, 100m Northings respectively.

To enter our Landranger reference of SP318658 into the GPS’s location field, we can pad each set of three digits on the right with zeroes, so we enter SP 31800 65800. Now you can navigate to a 100m × 100m square containing our postcode.

We can do better than that, though. Note the relationship between the “OS X”, “OS Y” and “LR” fields. If we knock off the two least significant digits from “OS X” and “OS Y”, then take the three remaining least significant digits from each, we get the same six digits that are in the Landranger reference.

       OS X:  431837
               |||
       LR  : SP318658
                  |||
       OS Y:     265809

The “OS X” and “OS Y” coordinates give us the location to 100 times greater precision than “LR”, but the 6th digit from the left in “OS X” and “OS Y” is absent from Landranger references, replaced by the “sheet” letters. (I say “6th digit from the right” instead of “first digit” because for some locations that digit is zero, which Streetmap does not print, instead giving you a 5 digit number.

Put all that together, and you get  SP 31837 65809.

Summary: take the two letters from the front of the “LR” field, then the last 5 digits of the “OS X” field, then the last 5 digits of the “OS Y” field. Assuming your GPS is configured to use the British grid, enter these into the “location” field in the GPS “Mark” panel.

Clearly this would be childsplay to automate.

41 Responses to “UK Postcodes to GPS Coordinates”

  1. Michael Sharpe Says:

    Question,

    My GPS does not allow for a negative Long value.

    I am using WGS84.

    I have tried using the locator in MS Streets and Trips and this does not
    give a negative value for the Long Value.

    Any Comments…I’m interested.

  2. John Says:

    Negative longitudes are quite common, so this seems odd.

    However, I think you could subtract the figure from 360 and get the same location.

    i.e. longitude -100 is equivalent to longitude 260.

  3. Tom C Says:

    Just wanted to say thank you for this greatly informative page. As new owner of a Garmin eTrex, it is just what I wanted. I found it by searching Google with “gps coordinates” and it was near the top of the list.

  4. Paul Lifton Says:

    Thanks for your help. I managed to get the OS grid reference and GPS coordinates for a customers website.
    All the best
    Paul

  5. Zubin Says:

    This may be slightly off topic but you seem to be quite knowledgeable in this area… my client needs to be able to enter two postcodes and get an approximate distance between them in miles. I understand that their are companies that have this service but my client’s budget cannot cover this. Also, I was involved in mapping US geographical data using comprehensive raw data provided for free by the US census bureau.

    Any advice would be hugely appreciated!

  6. Brett Says:

    Hi,

    I am currently trying to build my own POI database for TomTom Nav5 to show all BTOpenzone wireless hotspots. The info on your page is great and exactly what I’m looking for. However, the hotspots database I downloaded from BT has some 7500+ addresses and using the process you described might take a while (a very long while). So, was wondering if you knew of any products or services that can convert bulk addresses to Long/Lat?

    Thanks

  7. John Says:

    I don’t really have any experience in that, Brett, although I note some postcode software in my Google ads :D

    Otherwise, knock up a script using something like wget or cURL, put a respectable delay in (to avoid upsetting Streetmap) and leave it going for a few days.

  8. Brett Says:

    Thanks John, Managed to to setup a vba script in Excel to do the dirty work and already have a 1/4 of the gps cords for my address list. Another two night runs and I should be there!

    Thanks again.

  9. Damien Says:

    Hey Brett,

    How did you go about the VBA code?

    I’ve been trying this but can’t get it to work.

    Damien

  10. Brett Says:

    Hi Damien,

    First I done a quick formula to turn the postcodes into the web addresses I wanted, but guess I could have done it in VBA.

    Anyway, say my postcodes are in column A of sheet “WebAddresses” and I’ve removed all the spaces from them, Formula in column B is:


    =CONCATENATE("https://www.streetmap.co.uk/streetmap.dll?GridConvert?name=",LEFT(A1,LEN(A1)-3),"+",RIGHT(A1,3),"&type=Postcode")

    The VBA is something like this

    Sub GetLonglat()

    Dim InCellLoc As String
    Dim InCellCol As String
    Dim InCellRow As String
    Dim NameValue As String
    Dim AddressValue As String
    Dim OutCellLoc As String
    Dim OutCellLoc1 As String
    Dim OutCellLoc2 As String
    Dim OutCellCol As String
    Dim OutCellCol1 As String
    Dim OutCellCol2 As String
    Dim OutCellRow As String

    InCellCol = "B"
    InCellRow = "1"
    OutCellRow = "1"
    InCellLoc = InCellCol & InCellRow
    Sheets("WebAddresses").Select
    Do While Range(InCellLoc).Value ""
    Sheets("WebAddresses").Select
    Workbooks.Open Range(InCellLoc).Value
    PostcodeValue = Range("B11").Value
    LatitudeValue = Range("B12").Value
    LongditudeValue = Range("B13").Value
    ActiveWorkbook.Close (False)
    Sheets("WebAddresses").Select
    OutCellRow = CStr(CInt(OutCellRow) + 1)
    OutCellCol = "C"
    OutCellCol1 = "D"
    OutCellCol2 = "E"
    OutCellLoc = OutCellCol & OutCellRow
    OutCellLoc1 = OutCellCol1 & OutCellRow
    OutCellLoc2 = OutCellCol2 & OutCellRow
    Range(OutCellLoc).Value = PostcodeValue
    Range(OutCellLoc1).Value = LatitudeValue
    Range(OutCellLoc2).Value = LongditudeValue
    Sheets("WebAddresses").Select
    InCellRow = CStr(CInt(InCellRow) + 1)
    InCellLoc = InCellCol & InCellRow
    Loop
    End Sub

    You may get asked for a certificate the first time. If it persists, try changing https to http in the formula.

    Hope this helps
    Brett

  11. Brett Says:

    Should point out that I got most of the code from Dan Mabbutt’s article on visualbasic.about.com “Accessing Web Pages Using Excel VBA”

    Brett

  12. Dave Rignall Says:

    I have already done this in Excel. Happy to sell it to you but I’m not sure if the price is that factor. Not sure what others may charge but you can have mine for £120. The claculation is done via two ways, either pythagarus or circumferance method.

    Email on david.rignall@gmail.com

  13. Mike Ward Says:

    Hi Brett,

    I have been trying to get your visual basic code to work but it keeps on coming up with errors. Is there anything else I should know to get the macro to work?

    Mike

  14. Simon Says:

    Mike,

    Note that the code has been munged by posting:

    Some Microsoft helpfulness in changing normal quotes to ’smart quotes’ (the ones which try to look different for open and close quotes) so change them all back. Smart quotes are a weird Windows perversion of Ascii - VBA quite reasonably doesn’t recognise them as delimiters.

    And in the Do While line, the ‘not-equal’ (which should be a less-than greater-than pair), has been skipped entirely because it looks like an empty HTML tag, so put that back in (hoping the CODE tag works):


    Do While Range(InCellLoc).Value ""

    And if you have Option Explicit on you’ll need to Dim the three variables PostcodeValue et al.

    HTH

    Simon

  15. John Says:

    Thanks for pointing that out Simon.

    I’ve edited Brett’s post to put <code/> tags around the code, so the quotes should no longer be munged.

  16. Terry Says:

    Hi, and thanks for the great post. I would say that Streetmap provide a great service. They pay staff and bandwidth costs. They also license the OS data for Britain which retails at £122K pA[1].

    I would use this information sparingly, and not in a very automated fashion. If Streetmap discover too many people are leeching[2] their information, we’ll all lose the useful information.

    —————–
    [1] http://www.ordnancesurvey.co.uk/oswebsite/products/streetview/pdf/d02086_StView.pdf
    [2] http://en.wikipedia.org/wiki/Leeching

  17. GaZ Says:

    A very useful entry. Thanks John (and Debbie)!

    FYI, There’s a webpage dedicate to making every postcode open-for-all @ http://www.freethepostcode.org/.

    It’s not necessarily limited to the UK, either.

  18. Colin Says:

    Brett, tried to use you Excel/visual basic system of converting postcodes to Lat and Long. It partially works as I see the first postcade added to the Streetmap web page but the Lat Long do not get returned to the spradsheet. any ideas what is going wrong?

    Thanks

    Colin

  19. Richard Says:

    Colin - you need to run the macro ….

  20. Paul Says:

    Hi, i’ve just about to get a Garmin SP3, can you enter 7 digit postcodes into the unit?

    Thanks

    Paul

  21. Colin Says:

    Hi,

    Thanks for the great tips, especially regarding the gathering the data from the web. I cant seem to get it to work though, so was wondering whether anything has changed since, that would stop it from working.

    Thanks in advance

  22. Parick Says:

    Hi,

    Great article - going to have a crack at this this evening. Would it be possible for someone to send me a working spreadsheet that imports the coordinates please?

    Many Thanks
    Patrick

    mail@patrickavis.com

  23. John Says:

    Hi many thanks for the UK Postcodes to GPS Coordinates info it has been a great help to me. I use it in my Sat Nav in the car. It is far easier than putting in the address. A question for all you experts can anyone please help. I am trying to get a GPS Coordinate from a straight Lat & Lon, ie Lat 37.64820 N
    & Lon 0.78693. Can anyone help me with a simple method to convert one to the other. That’s if it is possible.

    Regards to all John

    jr.worthy@hotmail.com

  24. John Says:

    It depends on your GPS. My Garmin has a setting which allows you to enter Lat/Long coordinates directly.

  25. John Says:

    Try this:
    http://www.nearby.org.uk/conversions.cgi

  26. Issac Says:

    Is there any way that I can be traced using a GPS reciver thorugh internet, like if am outside and my GPS is working is there any application by which anybody can trace me sitting on computer?

  27. John Says:

    A GPS receiver is a completely passive device, so it shouldn’t be possible to trace you. However, some devices might be more than a simple GPS receiver. For example, if you were using a laptop with a GPS dongle, it’s conceivable that an application could take the location data from your GPS and send it on.

    Vehicle tracking devices do this, for example: a GPS receiver calculates its location, and sends out tracking information over the mobile phone network.

  28. Claire Says:

    Thanks so much for the information I have tested it on my home address and it works perfectly for me. Now when I get lost driving to friends out of the county I can pull over and use my hand held Garmin to help. You’ve also done your bit for the environment by saving me gallons of petrol.

  29. Jenny Woodruff Says:

    Hello John and Debbie,
    I’m really pleased to have found this information, and even more pleased to have found you guys again! Do you remember us? Terry and I used to go to the Gag club in Brum with you but we lost touch after you moved from your first place in Leamington. I was looking for postcode - grid ref converters as we are planning to move house ( from the one we built) and I thought this could help us determine optimum locations.
    Please get in touch - would love to hear from you ( not just about postcodes)

  30. John Says:

    Hi Jenny! I sent you an email.

  31. Pascal Says:

    Hi, Not sure if you could help but having read your site, i think you know more about the Garmin GPS than I do :) - I went on a geocahing hunt last week and found out that my GPS is about a 100m out!! I learned in the meantime that up untill a couple of years ago this was very common in the US, because of government interference in the signal.
    Have you got any idea as to why this could be? The GPS is set to WGS84.
    Should I throw it in the bin (or is this a too desperate measure?) hope you can send me in the right direction. Have been serving for answers without any luck. Cheers.

  32. John Says:

    Pascal, the GPS should show a circle on the map indicating its margin of error. If it can’t see many satellites (e.g. in the woods with lots of leaf cover) it will lose accuracy.

    Try it in a wide open space. If it’s still inaccurate, you should take it up with Garmin.

    Also, try and establish whether it’s your GPS that’s wrong or the map!

  33. Peter Says:

    Hi, firstly thanks for a great site, very informative. I have a ViaMichelin x-950 unit into which I’ve been trying to put GPS coordinates using the information above. The device I have doesn’t allow negative coordinates nor coordinates of more than 2 digits….I’m by no means an expert on map reading but wondered if you could point me in the direction of how to convert the coordinates received from multimap into a format understood by my unit. The format it uses for coordintates is: xx*xx,xxxx’ - where x is a digit, * is the degree symbol, four more digits followed by a single apostrophe.

    Once you enter the first set of coordinates you’re prompted for either an N or S (for North and South I assume) and the same format again withe E &W.

    However, putting in the coordinates (including the xx,xxxx format shown on multipmap after the latitude and longitude coordinates) doesn’t work either and I can’t find any way of putting in negative values (and subtracting from 360 won’t work as I only have 2 digits).

    Thanks for taking the time to read what I know is a long post.

    Any help would be greatly appreciated.

    Cheers

    Peter

  34. John Says:

    Peter, verify this with the unit’s docs, but I guess your xx*xx,xxxx’ is degrees, followed by minutes (an arc minute is a 60th of a degree, and is denoted by a ‘). I guess the comma is a European decimal point. Those crazy people use commas between Francs and Cents.

    N and W are positive, E and W are negative. But I don’t know how you’re meant to manage with only 2 digits, as you still need up to 180 degrees.

    Check the manual, and good luck!

  35. Daniel Says:

    Hi everyone,
    does anybody have a copy of the UK postcode coordinates in spreadsheet format?

  36. Mark Says:

    Hi - I need to automate the collection of grid references from post codes.
    I know very little about macro’s and even less about Visual Basic. However, I played about with the codes in the middle of this article and finally got something to work.
    Unfortunately what actually happened was that the answer I was after (the co-ordinates) wasn’t actually displayed in a cell in my spreadsheet but thrown up at lightning speed, equally quickly disappeared and with no apparent way of getting it back without re-running the macro again.

    What am I doing wrong? Any suggestions appreciated…

  37. John Says:

    I think you need to find a spreadsheet-savvy forum to ask that in.

    I don’t know much about spreadsheet macros or VB either, and I’m a little surprised by how much spreadsheet talk this article as attracted. If I was automating this kind of stuff, I’d use an ordinary programming language I was familiar with and which had an HTTP library (Perl, Ruby, Java, etc.), read the postcodes from a simple text file, and write them to a simple text file.

    If I needed a spreadsheet thereafter, I’d import from the text file.

  38. michael jones Says:

    Very good post! I have a GPS Laptop Receiver and it is really suitable and useful device!

  39. Daryl May Says:

    For hiking purposes, I’d be enormously grateful if someone could share a spreadsheet of all the UK postal codes and their geodetic coords. I see in this dialog that people have done that. I don’t need the methodology, just the result! Write to me at hikerguy(at)earthlink.net

    Thanks.

  40. Araç takip sistemi Says:

    very nice…

  41. Araç takip sistemi Says:

    Very good post!

Leave a Reply