UK Postcodes to GPS Coordinates
1,531 wordsSo 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
-
WGS84 is a standard reference system (”datum”) for
- 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.
June 29th, 2005 at 14:51
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.
June 29th, 2005 at 15:51
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.
August 18th, 2005 at 16:29
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.
September 14th, 2005 at 20:54
Thanks for your help. I managed to get the OS grid reference and GPS coordinates for a customers website.
All the best
Paul
September 15th, 2005 at 09:31
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!
September 22nd, 2005 at 09:49
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
September 22nd, 2005 at 10:19
I don’t really have any experience in that, Brett, although I note some postcode software in my Google ads
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.
September 23rd, 2005 at 15:59
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.
September 25th, 2005 at 17:48
Hey Brett,
How did you go about the VBA code?
I’ve been trying this but can’t get it to work.
Damien
September 27th, 2005 at 15:02
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
September 27th, 2005 at 15:07
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
October 14th, 2005 at 11:34
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
October 15th, 2005 at 18:14
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
October 18th, 2005 at 09:36
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
October 18th, 2005 at 10:12
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.
October 23rd, 2005 at 12:11
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
November 1st, 2005 at 16:49
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.
November 15th, 2005 at 14:13
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
December 2nd, 2005 at 09:29
Colin - you need to run the macro ….
December 5th, 2005 at 21:31
Hi, i’ve just about to get a Garmin SP3, can you enter 7 digit postcodes into the unit?
Thanks
Paul
January 10th, 2006 at 17:53
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
March 2nd, 2006 at 17:58
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
May 27th, 2006 at 12:23
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
May 30th, 2006 at 12:42
It depends on your GPS. My Garmin has a setting which allows you to enter Lat/Long coordinates directly.
May 30th, 2006 at 12:44
Try this:
http://www.nearby.org.uk/conversions.cgi
August 17th, 2006 at 13:52
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?
August 17th, 2006 at 14:40
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.
August 18th, 2006 at 00:02
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.
August 18th, 2006 at 12:12
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)
August 19th, 2006 at 09:15
Hi Jenny! I sent you an email.
October 24th, 2006 at 19:24
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.
October 30th, 2006 at 13:48
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!
March 25th, 2007 at 21:12
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
March 26th, 2007 at 08:19
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!
September 27th, 2007 at 10:06
Hi everyone,
does anybody have a copy of the UK postcode coordinates in spreadsheet format?
November 27th, 2007 at 17:49
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…
November 28th, 2007 at 10:09
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.
December 11th, 2007 at 16:36
Very good post! I have a GPS Laptop Receiver and it is really suitable and useful device!
December 14th, 2007 at 20:34
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.
December 17th, 2007 at 00:28
very nice…
December 17th, 2007 at 00:28
Very good post!