Visokio website     Downloads     Video tutorials     KnowledgeBase  
Mapping: Coordinate conversion-Lat/Long to British National Grid (2.7+) - Visokio Forums
Mapping: Coordinate conversion-Lat/Long to British National Grid (2.7+)
  •     chris November 18, 2011 10:20AM
    Hi,

    In tonights 2.7 release you will see we have added two new functions:

    CONVERT_LATLONG_TO_OSGBX and CONVERT_LATLONG_TO_OSGBY

    These allow you to convert a coordinate from GPS lat/long to British national grid. The provide the opposite behaviour to the existing functions:

    CONVERT_OSGB_TO_LAT and CONVERT_OSGB_TO_LON
  • 16 Comments
  •        daniel November 21, 2011 3:42AM
    Thanks, this could prove to be very useful to me and hopefully others may find this useful too.

    I found myself interested in this for using the OSGB coords to calculate distance betwen two points. It should be able now to create a specific distance radius around a given XY pair.
  •     chris November 21, 2011 4:06AM
    Hi Daniel,

    Thanks for the comment. Would a LAT_LONG_DISTANCE function be useful, where you pass in two sets of lat/long coordinates?
  •        daniel November 21, 2011 4:26AM
    That would be quite helpful to have something quick like that.

    It would save me time as I was going to base the calculation by creating multiple column fields and the distance calculations separately as below using OSGB coordinates:

    image

    *HYP is going to be a static radius measurement i.e. 1000 for a single kilometer.


    I would imagine the function will be like LAT_LONG_DIST( (LatitudeField),(LongitudeField), ( Example Ref Point Lat/long: 54.123,1.2344))?

    Which should generate a new field of just the distance from the specified point. From there I can run a simple logic function to say if(distance > 1000, "Accept", "Reject").
  •     chris November 21, 2011 4:47AM
    Sounds good. We will look at implementing this in the next day or so.
  •     peterg_at_aps November 24, 2011 4:44AM
    Using lat lon would be more universally applicable.

    To get distance in miles I have found the following formulae useful in Excel

    =ACOS(COS(RADIANS(90-latitude1)) *COS(RADIANS(90-latitude2)) +SIN(RADIANS(90-latitude1)) *SIN(RADIANS(90-latitude2)) *COS(RADIANS(longitude1-longitude2))) *6371/1.609

    I think this could easily be adapted for Omniscope.

    I think it tries to compensate for the fact that at extreme latitudes Pythagoras theorem breaks down.

    There is quite a lot on the web regarding calculation of distance by the great circle method which should recognise Earth's curvature and explains why aircraft fly from London to Atlanda via cold Northern places.

    Hope this helps - and a distance function would be very useful indeed. Keep up the good work!

  •     chris November 24, 2011 4:49AM
    Hi,

    We have now added the function LAT_LONG_DISTANCE which calculates the surface distance between two sets of Lag/Long coordinates. It returns the result in KM.

    This is available in the latest version of Omniscope 2.7.
  •     peterg_at_aps November 24, 2011 1:18PM
    Its there and it worked for me - good work!
  •        benjamin February 24, 2012 9:33AM
    In the script function it says LAT_LONG_DISTANCE undefined.

    Why is this ?
  •     steve February 24, 2012 9:55AM
    Only a few functions are currently available in JavaScript. These are labelled "in scripts" in the functions guide - e.g. http://www.visokio.com/kb/functions-guide#INVERSE

    For those that aren't labelled, you have to evaluate them using an embedded text formula.

    For example:

    SCRIPT(
    `
    formula("lat_lon_distance("+lat1+", "+lon1+", "+lat2+", "+lon2+")")
    `,
    /* London... */
    "lat1", 51.508129,
    "lon1", -0.128005,
    /* Auckland... */
    "lat2", -36.84846,
    "lon2", 174.763332
    )


  •     sherriff July 26, 2013 4:52AM
    Hi
    I have some OSGB36 grid references. eg: ST5739166513

    How should I convert this to OSGBX and OSGBY to use in the Omniscope LAT LONG conversion formula?
  •        daniel July 26, 2013 5:54AM
    Here is a good explanation of how to convert, the author has some javascript implementation to do conversions. I can't help with figuring that out but perhaps one of the devs will be able to implement it for you.

    http://www.movable-type.co.uk/scripts/latlong-gridref.html

  •     richard July 26, 2013 7:26AM
    Attached is an example using the script Daniel found with an Omniscope 'Custom Script' operation to do the conversion.

    You may need to tweak the bottom of the script a little to make it more robust for your data.
    Attachments
    OSGB Conversion.iok 11K
  •        daniel July 26, 2013 7:41AM
    Just an idea, do you think its possible to create favourite bookmarks for script blocks just like the one you did?
  •     chris July 26, 2013 8:56AM
    Hi,

    That's a great idea. Unfortunately it's not possible to do this at the moment. The difficulty in bookmarking operations is that they require input data in order for you to be able to configure them. Obviously the "Custom Script" operation does not have that limitation, so in principle it would be possible.

    Rather than using bookmarks we could have a script library, which would work in a similar way to the R-statistics library. When you dragged on a custom script block you could enter a new script or select a pre-configured script from the library. This would mean we could have an Omniscope library, which would contain scripts that were general purpose and useful for all users, and a user library where individual Omniscope users could create their own scripts.

    This would be a relatively easy update for us to perform, so it might be worth creating an idea and seeing how many other users would find this functionality useful.

    We have considered combining the "R-statistics", "Remote operation" and "Custom script" blocks into a single "Custom operation" block that would let you choose what type of operation you wanted to perform, select the parameters and configure the operation. So, for example, you could configure it to run an executable or upload data to a web service. You could then export operations from your library to other users. This would be a fairly substantial piece of work and hasn't been of high-enough priority up to now, but potentially it would be quite powerful.
  •        daniel August 6, 2013 6:28AM
    Just wanted a clarification of how the LAT_LON_DISTANCE formula works, is it based of the Haversine formula implementation like http://www.movable-type.co.uk/scripts/latlong.html ?

  •     richard August 6, 2013 9:20AM
    Hi Daniel

    We use Spherical Law of Cosines with a radius of 6366.707km. The formula is outlined here - http://www.movable-type.co.uk/scripts/latlong.html.

Welcome!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership