Closed Thread
Results 1 to 15 of 15

Converting Latitude/longitude to OSGB grid ref

  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6

    Converting Latitude/longitude to OSGB grid ref

    Hi,

    I'm very new to using Excel for programming etc, so there may well be an easy fix for my problem.

    I'm using excel to try and sort by distance a list of wind farm locations from a location i put in.

    This should be relitavely straight forward, however there are a few elements that make it more complicated.

    I am getting a list of wind farm locations from the internet, the BWEA site. The latitude and longitude data copied over is in text. I'm using Excel '07 but it still requires me to butcher the numbers out of it with several columns of REPLACE formulas, it isn't elegant and may well be wrong, so a better way of doing this would help a lot.

    The second and harder problem is that I have to first convert the latitude and lonitude values into OSGB grid references. So far i have found the OS maps excel converter, but it only converts one value at a time. I need something that will convert all of them at once (i don't want to go through and individually type in each distance).

    After that it is possible to use basic trigonometry to find the distance between them and any grid reference i put in.

    Cheers for any help you can give

    Tom

  2. #2
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6
    I have spent this afternoon producing a reduced version of the spreadsheet that hopefully doesn't need a macro - However it means the formulaes involved are exceptionally long and complicated.

    What is more annoying is that it still doesn't come put with the right answer!! -And I don't know why, only that there is an error before the column named 'v' (column z). It may be a simple error (equivalent to looking for my glasses when they're on my head) But i can't seem to spot it.

    The helpful guide i am using is from the OS website - the Pdf. Appendix C is what i am trying to do!

    Again any help is much appreciated.

    Cheers

    T
    Attached Files Attached Files

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    I'll look at this later today if no one else solves it in the meanwhile.

    The goal is just to convert WGS-84 lat/long coordinates (received as d m s in a space-delimited string) to OSGB coordinates?

  4. #4
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6
    Hi,

    Yup basically that's it! - however, it's a lot harder than it first appears (or so i've found!)

    Thanks a lot for havinga look at it.

    T

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    It's the first section in App C, correct?

    Does the worked example use the same phi0 and lambda0 (49 and -2 respectively) that you show in the spreadsheet?

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    For the worked example, the function returns the Easting exactly in accordance with the worked example, and the Northing with a 0.001% error. I don't see a mistake in the formulas, but did not look carefully.

    The UDF requires a two-cell wide array formula. Usage is

    =WGS84ToOSGB(lat, lon) (arguments in radians, north and east positive)

    Array formulas MUST be confirmed with Ctrl+Shift+Enter, not Enter. You'll know you did it correctly if curly braces appear around the formula in the Formula Bar; you cannot type in the braces directly.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6
    Wow!

    Thanks that looks great - im just going to try it out now!

    Thanks so much for the help. I hope it wasn't too much hassle!

    T

  8. #8
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6
    Right I think i got it almost fully sorted!

    There is a little niggle in that the triginometry bit to figure out the distances between the input location (in green) and the wind farms aren't quite right, but i hope i shall be able to find out what it is and sort it by later on today.

    I've attached the file so you can see what you have helped create (and also in the hope you (or someone else) could see what is causing the distances to go wrong in the 'Reformatted ....' sheets).

    Thanks again for your help

    T

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Hey, Greenspan,

    I found the error. Look at equation C3 in the PDF. That term 35/24 n^3 that has the long virgule should actually be a -sign before the fraction. I changed the code and now the Northing comes out spot-on.

    Replace the code with this:


    Please Login or Register  to view this content.
    I don't know if that will fix your other problem or not. If not, please explain.
    Last edited by shg; 08-01-2008 at 12:38 PM.

  10. #10
    Registered User
    Join Date
    07-30-2008
    Location
    Edinburgh
    Posts
    6
    Fantastic it's all done and dusted

    Thank you very much! You have been a really great help!



    Greenspan

  11. #11
    Registered User
    Join Date
    05-09-2012
    Location
    Camberley, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Converting Latitude/longitude to OSGB grid ref

    Hi, I've only just joined the forum and already it's solved a problem that's been bugging me for a while: how to convert a batch of GPS locations in lat/long form to OS grid references. This routine is great. My lat/long values are actually in decimal degrees, not dms, but by substituting the function RADIANS(angle), where angle is the lat or long in my format, for the version in the download, I've now got just what I want. Thanks.

  12. #12
    Registered User
    Join Date
    03-27-2014
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Converting Latitude/longitude to OSGB grid ref

    Nice, I didnt think this was possible

  13. #13
    Registered User
    Join Date
    12-09-2014
    Location
    Staffordshrie, United Kingdom
    MS-Off Ver
    MS Office 2003
    Posts
    1

    Re: Converting Latitude/longitude to OSGB grid ref

    This is what I am looking for also. I am a newbie in excel formulas and all looks really difficult to me. I will try to use the formula shg provided and see if it works on mine lat/long lists I have got. Many thanks in advance.

  14. #14
    Registered User
    Join Date
    07-10-2020
    Location
    clydebank
    MS-Off Ver
    2007
    Posts
    2

    Re: Converting Latitude/longitude to OSGB grid ref

    Hi Guys
    Very new to excel, but here goes.
    Is there a way of batch converting Lat/Long to OS grids with alpha numerical,10 digit (55.920860,-4.402973 is NS49857 72357)

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Converting Latitude/longitude to OSGB grid ref

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1