This is my first post, so apologies if i've messed up anywhere....
I've been using a javascript converter from http://www.carabus.co.uk/ to change a UK Grid Ref in a Latitude Longitude for google maps. However I needed to convert 100's on the fly in VBScript so have re- written the functions in ASP.
My maths isn't that great (some might say my VBScript isn't much better) so use at own risk.
SM856127 = 51.7713932226388, -5.10791492926723
My code can be found - http://nt.pcnpa.org.uk/Walks/Admin/ netoll_how2.asp please note: i've only just completed this and it needs tidying up. On the tests that i've done it's been fine but any errors please mention them on here for other people to see and laugh at my rubbish code.
USEAGE : Essentially put the functions at the top of the page and the remaining code between the body tags.
Welcome to the group. It looks to be fine from a quick glance, although I'm not a VB expert.
If you (or anybody else) plan to use this for converting from OS grid references to use on Google Maps, bear in mind that this doesn't take account of the different datums they use. OS uses the OSGB 1936 datum, whereas Google Maps (and GPS, etc.) use the WGS 84 datum. The difference isn't massive, but it definitely makes a difference for street level mapping - points can be on different roads.
I've got some code somewhere that converts that, in PHP and JS. I can dig it out if anybody needs it - don't be offended if I don't reply straight away, since I'll be away from email for a few days.
Pete you might be interested in this http://www.bdcc.co.uk/mendip.html National Grid overlayed when selected UK OS Now zoom out and you can clearly see the Grid distorting. That Transverse Mercator (OS Grid Base) The Google Maps projection is the the Mercator Geographic (lat/long) WGS84 projection as Bert describes. The distortion is called convergence http://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinates...
> This is my first post, so apologies if i've messed up anywhere....
> I've been using a javascript converter fromhttp://www.carabus.co.uk/ > to change a UK Grid Ref in a Latitude Longitude for google maps. > However I needed to convert 100's on the fly in VBScript so have re- > written the functions in ASP.
> My maths isn't that great (some might say my VBScript isn't much > better) so use at own risk.
> SM856127 = 51.7713932226388, -5.10791492926723
> My code can be found -http://nt.pcnpa.org.uk/Walks/Admin/ > netoll_how2.asp > please note: i've only just completed this and it needs tidying up. On > the tests that i've done it's been fine but any errors please mention > them on here for other people to see and laugh at my rubbish code.
> USEAGE : Essentially put the functions at the top of the page and the > remaining code between the body tags.
As you may have guessed a lot of this mapping stuff is way over my head (i'm a web developer and not a GIS person). Luckily the project i'm working on only concerns Pembrokeshire - that's another downfall of my code, i've only got the conversions in there for SN, SM, SS & SR areas. The other lucky thing is that the positions only need to be accurate to a few feet (that's another failing of my code i'm only passing SN123456 which will only ever be accurate to a few meters (ish?) or so at the moment)
Mapperz, funnily enough i was looking at the OS site earlier tonight and noticed the conversion pages - I was going to have a better look in work tomorrow, as i assumed the program download would be for GIS applications and not actual source code?
Thanks again folks, hopefully as i get to grips with the mapping side i'll be able to write a better tool. There doesn't seem to be much of it about on the web to use with classic ASP. I hope that other people like yourselves with a better understanding of GIS or coding will be able to point me in the right direction.
> The other lucky thing is that the positions only need to be > accurate to a few feet (that's another failing of my code i'm only > passing SN123456 which will only ever be accurate to a few meters > (ish?) or so at the moment)
SN123456 is a 6 figure reference and as such can be thought of as truncated to the nearest 100m. So that reference actually defines a box of 100m x 100m.
Converting to a 10figure reference might make it clearer SN123456 SN 123 456 SN 12300 45600
On a 10 fig ref, the numbers are actually whole meters
Similarlly a 8 fig like SN12345678 defines a 10m x 10m box SN12345678 SN 1234 5678 SN 12340 56780
Hope that helps,
(btw I've often been asked about asp code, but have never actually found anyone who has converted the code!)
> > The other lucky thing is that the positions only need to be > > accurate to a few feet (that's another failing of my code i'm only > > passing SN123456 which will only ever be accurate to a few meters > > (ish?) or so at the moment)
> SN123456 is a 6 figure reference and as such can be thought of as truncated > to the nearest 100m. So that reference actually defines a box of 100m x > 100m.
> Converting to a 10figure reference might make it clearer > SN123456 > SN 123 456 > SN 12300 45600
> On a 10 fig ref, the numbers are actually whole meters
> Similarlly a 8 fig like SN12345678 defines a 10m x 10m box > SN12345678 > SN 1234 5678 > SN 12340 56780
> Hope that helps,
> (btw I've often been asked about asp code, but have never actually found > anyone who has converted the code!)
I've tried 2 different things using classic asp. One of them required a dll to be registered on the server. I use a hosted account and ultimately couldn't get the thing working. I then tried a PHP script I got from Barry. I just called the PHP script on the fly by passing a param (NGR) from classic asp and parsed the response to get Lat/Lon.
Yeah, i'd be interested to have look at the code, although i've never done any PHP.
Out of interest, was the DLL version from the OS website ? I might have a look at that method in the future, to see if there are any speed gains to be had.
If anyone is interested the URL where i'm developing currently is below. Please note this is not the front end and was only intended for content authors to have a look at the data they're entering. The brief was to have our National Trail on an interactive map. The trail is broken into sections (1 - 15) each section can have x number of walks and each walk has descriptives, which talk about that part of the walk. you can then choose which direction to walk N -> S or S -> N.
The accommodation puts markers on the map (if they have an OS ref to convert) which is how i got into this whole google group in the first place!
http://nt.pcnpa.org.uk/Walks/Admin/preview.asp To use, enter start and end sections as 1 and then click things on/off (note the map dropdown!) (best viewed in FireFox at the moment) THIS IS VERY MUCH IN DEVELOPMENT (so don't be suprised if it's not working or there are ASP errors all over the place)
On the weekend, i'll try and put my code up on my website, along with information that i've found useful to get this far and put a link on here.
I though I might join in, since the carabus website belongs to me.
The conversion code from OSGB36 lat/lon to NGR is based on OSGB documents, and is mainly a javascript rewrite of the VBA code embedded in the Excel workbook found on the Ordnance Survey website. Similarly the datum transformation code on carabus.co.uk also comes from the same OS site. So the results should be as good as anything freely available, barring coding errors.
I would be interested in any feedback on the conversions from the Irish Grid (which I think is OK) and particularly the Channel Island grids. I've used the same formulae with what I think are appropriate constants, but have been unable to find any reliable reference data.
Also my code to convert to and from OS grid letters is a bit strange. It works but I'm sure there's a more elegant method.
> I though I might join in, since the carabus website belongs to me.
> The conversion code from OSGB36 lat/lon to NGR is based on OSGB > documents, and is mainly a javascript rewrite of the VBA code embedded > in the Excel workbook found on the Ordnance Survey website. Similarly > the datum transformation code on carabus.co.uk also comes from the > same OS site. So the results should be as good as anything freely > available, barring coding errors.
> I would be interested in any feedback on the conversions from the > Irish Grid (which I think is OK) and particularly the Channel Island > grids. I've used the same formulae with what I think are appropriate > constants, but have been unable to find any reliable reference data.
> Also my code to convert to and from OS grid letters is a bit strange. > It works but I'm sure there's a more elegant method.
This gives the same results (within a metre) as my code for GB and Ireland, so that's comforting. What I'm looking for is something like http://www.gps.gov.uk which lists both lat/lon and National Grid for GPS Passive Stations.
Incidentally, http://gps.ordnancesurvey.co.uk/convert.asp features a coordinate transformer for Great Britain and Ireland. The Passive Station data is available from this page but alas only covers GB.
> This gives the same results (within a metre) as my code for GB and > Ireland, so that's comforting. What I'm looking for is something like > http://www.gps.gov.uk which lists both lat/lon and National Grid for > GPS Passive Stations.
with inputs values such as eastings,northings 529929.35,185874.14 529932.87,185877.47
the Ord Surv outputs for these are: N 51.55679837, W 0.12717995 N 51.55682749,W 0.12712798
so in the google maps search box I'm putting in 51.55679837, -0.12717995 51.55682749,-0.12712798
(These locations are actually positions of road bollards in north London - don't ask me why I'm interested in locations of bollards - it's a long story!!)
If you look at google maps satellite zoomed all the way in you can see that the locations google location pointers are about 2 m from where the photos show the bollards. Google shows the locations about 2m too far north and slightly to the east.
I'm wondering if there's any way of getting things more accurate than this.. or is this as good as it gets given the input coordinates resolutions? (I tried using different ground height values e.g. 100m or 200m but these don't seem to make any difference to the lat long that the Ord Surv outputs)
Greatly appreciate any further guidance. Thanks Will
On Feb 1, 7:57 pm, "mapp...@googlemail.com" <mapp...@googlemail.com> wrote:
> Pete you might be interested in thishttp://www.bdcc.co.uk/mendip.html > National Grid overlayed when selected UK OS > Now zoom out and you can clearly see the Grid distorting. That > Transverse Mercator (OS Grid Base) > The Google Maps projection is the the Mercator Geographic (lat/long) > WGS84 projection as Bert describes. The distortion is called > convergencehttp://www.ordnancesurvey.co.uk/oswebsite/gps/information/coordinates...
> On Feb 1, 2:47 pm, "Skibutt" <skib...@gmail.com> wrote:
> > Hello,
> > This is my first post, so apologies if i've messed up anywhere....
> > I've been using a javascript converter fromhttp://www.carabus.co.uk/ > > to change a UK Grid Ref in a Latitude Longitude for google maps. > > However I needed to convert 100's on the fly in VBScript so have re- > > written the functions in ASP.
> > My maths isn't that great (some might say my VBScript isn't much > > better) so use at own risk.
> > My code can be found -http://nt.pcnpa.org.uk/Walks/Admin/ > > netoll_how2.asp > > please note: i've only just completed this and it needs tidying up. On > > the tests that i've done it's been fine but any errors please mention > > them on here for other people to see and laugh at my rubbish code.
> > USEAGE : Essentially put the functions at the top of the page and the > > remaining code between the body tags.
Frankly I am amazed you are getting 2m accuracy. (amazed in a good way!)
The OS online converter is actually giving you ETRS89 coordinates which don't exactly match WGS84 datam which Google Maps uses [1]. The difference is quite small, I believe currently on the order of 25cm, so that probably is not whole cause of the 2m difference. There's a program quoted on that page that reportedly converts, you might try converting to WGS84 for maximum accuracy.
The number of decimal places on your lat/long's should be accurate enough for this. [2] Shows that they are able to realise a position to at least cm precision. (in fact I should upgrade that tool to quote sub cm)
What is more likely is the georeferencing of the satellite images is not this accurate and/or off a little bit. If you notice the Hybrid road layers disappear at these exceptional zoom levels, probably reinforcing that Google (and/or its suppliers) don't believe that they match *that* accurately.
Also to get this sort of accuracy you will have to use the definitive conversion on the OS website (or reimplemented, or use of the DLL) rather than any of the PHP/Perl/ASP etc scripts here which are only accurate to around 7m. (which is usually good enough for GPS work)
> with inputs values such as > eastings,northings > 529929.35,185874.14 > 529932.87,185877.47
> the Ord Surv outputs for these are: > N 51.55679837, W 0.12717995 > N 51.55682749,W 0.12712798
> so in the google maps search box I'm putting in > 51.55679837, -0.12717995 > 51.55682749,-0.12712798
> (These locations are actually positions of road bollards in north > London - don't ask me why I'm interested in locations of bollards - > it's a long story!!)
> If you look at google maps satellite zoomed all the way in you can see > that the locations google location pointers are about 2 m from where > the photos show the bollards. Google shows the locations about 2m too > far north and slightly to the east.
> I'm wondering if there's any way of getting things more accurate than > this.. or is this as good as it gets given the input coordinates > resolutions? (I tried using different ground height values e.g. 100m > or 200m but these don't seem to make any difference to the lat long > that the Ord Surv outputs)
> Greatly appreciate any further guidance. > Thanks > Will
However see Flash Earth: http://www.flashearth.com/?lat=51.55679837&lon=-0.12717995&z=5.6&r=0&... which working outside the API is not likely to same the same inherent accuracy issues. But gives a similar position, showing the google imagery might indeed be out. Comparing it to the MS Virtual Earth, basically confirms this, IMHO that will be better registered because of the way and purpose it was captured by getmapping.com.
> Frankly I am amazed you are getting 2m accuracy. (amazed in a good way!)
> The OS online converter is actually giving you ETRS89 coordinates which > don't exactly match WGS84 datam which Google Maps uses [1]. The difference > is quite small, I believe currently on the order of 25cm, so that probably > is not whole cause of the 2m difference. There's a program quoted on that > page that reportedly converts, you might try converting to WGS84 for maximum > accuracy.
> The number of decimal places on your lat/long's should be accurate enough > for this. [2] Shows that they are able to realise a position to at least cm > precision. (in fact I should upgrade that tool to quote sub cm)
> What is more likely is the georeferencing of the satellite images is not > this accurate and/or off a little bit. If you notice the Hybrid road layers > disappear at these exceptional zoom levels, probably reinforcing that Google > (and/or its suppliers) don't believe that they match *that* accurately.
> Also to get this sort of accuracy you will have to use the definitive > conversion on the OS website (or reimplemented, or use of the DLL) rather > than any of the PHP/Perl/ASP etc scripts here which are only accurate to > around 7m. (which is usually good enough for GPS work)
> > with inputs values such as > > eastings,northings > > 529929.35,185874.14 > > 529932.87,185877.47
> > the Ord Surv outputs for these are: > > N 51.55679837, W 0.12717995 > > N 51.55682749,W 0.12712798
> > so in the google maps search box I'm putting in > > 51.55679837, -0.12717995 > > 51.55682749,-0.12712798
> > (These locations are actually positions of road bollards in north > > London - don't ask me why I'm interested in locations of bollards - > > it's a long story!!)
> > If you look at google maps satellite zoomed all the way in you can see > > that the locations google location pointers are about 2 m from where > > the photos show the bollards. Google shows the locations about 2m too > > far north and slightly to the east.
> > I'm wondering if there's any way of getting things more accurate than > > this.. or is this as good as it gets given the input coordinates > > resolutions? (I tried using different ground height values e.g. 100m > > or 200m but these don't seem to make any difference to the lat long > > that the Ord Surv outputs)
> > Greatly appreciate any further guidance. > > Thanks > > Will
Yes MS Virtual Earth looks slightly better perhaps.
Thinking about all this for my needs, on whichever service and api I go with in the end, I can probably do a conversion (i.e. to within the 2m type accuracy above) and apply a fudge translation factor to the lat long input values so that all the items (bollards & street lights) I'm showing all line up pretty exactly to the aerial photography. The largest area I'll be doing this for is typically a UK county so hopefully the fudge is uniform enough over that area.
> However see Flash Earth:http://www.flashearth.com/?lat=51.55679837&lon=-0.12717995&z=5.6&r=0&... > which working outside the API is not likely to same the same inherent > accuracy issues. But gives a similar position, showing the google imagery > might indeed be out. Comparing it to the MS Virtual Earth, basically > confirms this, IMHO that will be better registered because of the way and > purpose it was captured by getmapping.com.
> Confused enough now? (I know I am)
> On 2/14/07, Barry Hunter wrote:
> > Frankly I am amazed you are getting 2m accuracy. (amazed in a good way!)
> > The OS online converter is actually giving you ETRS89 coordinates which > > don't exactly match WGS84 datam which Google Maps uses [1]. The difference > > is quite small, I believe currently on the order of 25cm, so that probably > > is not whole cause of the 2m difference. There's a program quoted on that > > page that reportedly converts, you might try converting to WGS84 for maximum > > accuracy.
> > The number of decimal places on your lat/long's should be accurate enough > > for this. [2] Shows that they are able to realise a position to at least cm > > precision. (in fact I should upgrade that tool to quote sub cm)
> > What is more likely is the georeferencing of the satellite images is not > > this accurate and/or off a little bit. If you notice the Hybrid road layers > > disappear at these exceptional zoom levels, probably reinforcing that Google > > (and/or its suppliers) don't believe that they match *that* accurately.
> > Also to get this sort of accuracy you will have to use the definitive > > conversion on the OS website (or reimplemented, or use of the DLL) rather > > than any of the PHP/Perl/ASP etc scripts here which are only accurate to > > around 7m. (which is usually good enough for GPS work)
> > > with inputs values such as > > > eastings,northings > > > 529929.35,185874.14 > > > 529932.87,185877.47
> > > the Ord Surv outputs for these are: > > > N 51.55679837, W 0.12717995 > > > N 51.55682749,W 0.12712798
> > > so in the google maps search box I'm putting in > > > 51.55679837, -0.12717995 > > > 51.55682749,-0.12712798
> > > (These locations are actually positions of road bollards in north > > > London - don't ask me why I'm interested in locations of bollards - > > > it's a long story!!)
> > > If you look at google maps satellite zoomed all the way in you can see > > > that the locations google location pointers are about 2 m from where > > > the photos show the bollards. Google shows the locations about 2m too > > > far north and slightly to the east.
> > > I'm wondering if there's any way of getting things more accurate than > > > this.. or is this as good as it gets given the input coordinates > > > resolutions? (I tried using different ground height values e.g. 100m > > > or 200m but these don't seem to make any difference to the lat long > > > that the Ord Surv outputs)
> > > Greatly appreciate any further guidance. > > > Thanks > > > Will
Microsoft (or more correctly getmapping.com which M$ reuse) - will be higher resolution for virtually all of Great Britain, as they have consistent at least 25cm imagery for the whole country, (some parts go to 12.5cm!), which was captured 1999-2003. [1]
However in select places Google (well their suppliers) will have more recent imagery (even some 2006), but little imagery better than 25cm for GB (if at all).
> Yes MS Virtual Earth looks slightly better perhaps.
> Thinking about all this for my needs, on whichever service and api I > go with in the end, I can probably do a conversion (i.e. to within the > 2m type accuracy above) and apply a fudge translation factor to the > lat long input values so that all the items (bollards & street lights) > I'm showing all line up pretty exactly to the aerial photography. The > largest area I'll be doing this for is typically a UK county so > hopefully the fudge is uniform enough over that area.
> I'm sure I can find this out, but is the MS VE photo data more recent > and/or better?
> Will
> On Feb 14, 3:13 pm, "Barry Hunter" <barrybhun...@googlemail.com> > wrote: > > In fact it might look like the Maps site (and possibly the API) have > some > > rounding, which could account for this.
> > However see Flash Earth: > http://www.flashearth.com/?lat=51.55679837&lon=-0.12717995&z=5.6&r=0&... > > which working outside the API is not likely to same the same inherent > > accuracy issues. But gives a similar position, showing the google > imagery > > might indeed be out. Comparing it to the MS Virtual Earth, basically > > confirms this, IMHO that will be better registered because of the way > and > > purpose it was captured by getmapping.com.
> > Confused enough now? (I know I am)
> > On 2/14/07, Barry Hunter wrote:
> > > Frankly I am amazed you are getting 2m accuracy. (amazed in a good > way!)
> > > The OS online converter is actually giving you ETRS89 coordinates > which > > > don't exactly match WGS84 datam which Google Maps uses [1]. The > difference > > > is quite small, I believe currently on the order of 25cm, so that > probably > > > is not whole cause of the 2m difference. There's a program quoted on > that > > > page that reportedly converts, you might try converting to WGS84 for > maximum > > > accuracy.
> > > The number of decimal places on your lat/long's should be accurate > enough > > > for this. [2] Shows that they are able to realise a position to at > least cm > > > precision. (in fact I should upgrade that tool to quote sub cm)
> > > What is more likely is the georeferencing of the satellite images is > not > > > this accurate and/or off a little bit. If you notice the Hybrid road > layers > > > disappear at these exceptional zoom levels, probably reinforcing that > Google > > > (and/or its suppliers) don't believe that they match *that* > accurately.
> > > Also to get this sort of accuracy you will have to use the definitive > > > conversion on the OS website (or reimplemented, or use of the DLL) > rather > > > than any of the PHP/Perl/ASP etc scripts here which are only accurate > to > > > around 7m. (which is usually good enough for GPS work)
> > > > with inputs values such as > > > > eastings,northings > > > > 529929.35,185874.14 > > > > 529932.87,185877.47
> > > > the Ord Surv outputs for these are: > > > > N 51.55679837, W 0.12717995 > > > > N 51.55682749,W 0.12712798
> > > > so in the google maps search box I'm putting in > > > > 51.55679837, -0.12717995 > > > > 51.55682749,-0.12712798
> > > > (These locations are actually positions of road bollards in north > > > > London - don't ask me why I'm interested in locations of bollards - > > > > it's a long story!!)
> > > > If you look at google maps satellite zoomed all the way in you can > see > > > > that the locations google location pointers are about 2 m from where > > > > the photos show the bollards. Google shows the locations about 2m > too > > > > far north and slightly to the east.
> > > > I'm wondering if there's any way of getting things more accurate > than > > > > this.. or is this as good as it gets given the input coordinates > > > > resolutions? (I tried using different ground height values e.g. 100m > > > > or 200m but these don't seem to make any difference to the lat long > > > > that the Ord Surv outputs)
> > > > Greatly appreciate any further guidance. > > > > Thanks > > > > Will
On Feb 15, 11:57 am, "Anthony Cartmell" <ajcartm...@fonant.com> wrote:
> >> 529932.87,185877.47
> > Where's that data from? How do you know it's accurate to a single cm, > > which is what the second decimal place indicates?
> FWIW, integer references are accurate to 100m, one decimal point to 10m, > and two decimals to 1m.
You're a factor of 100 out there.
OS national grid references are the number of metres (in the projection) from a particular point somewhere SW of the Isles of Scilly. 529932.87,185877.47 as a six figure Landranger style grid reference is TQ 299 859. The TQ refers to a particular 100 km square [1], corresponding to the first numbers in the decimal reference. 299 and 859 narrow that down to a 100 m square. You could also give the Landranger style reference as TQ 29933 85877 to give a 1 m square.
Also, bear in mind the difference between accuracy and precision. Just because a position is quoted to a precision of (say) a metre doesn't mean it's accurate to a metre - the original measurement could have been way out.
[1] Actually, the T refers to a 500 km square and the Q one of the 25 100 km squares in that. They're lettered from top to bottom, left to right, using A-Z excluding I. AA is somewhere way off to the North West of Scotland, and never appears on real maps. Same for ZZ - somewhere in continental Europe.
where I was writing the more accurate Landranger-style references as TQ 299.33 858.77 which was confusing me (and was what I based my erroneous info on...).