5

I have a fairly accurate formula (implemented in C#), which allows me to convert UK Eastings/Northings to WGS84 Latitudes and Longitudes. Despite extensive Google searches, I could not find a formula to perform the reverse transformation. Could anyone point me in the right direction (a JavaScript/C# example would be ideal)?

6

I'd recommend using something like the proj4 library, which has wrappers in several languages, including JavaScript - Proj4JS. For C#, there's proj4net

It has the advantage you can translate between all sorts of projections, not just OSGB.

I'm not a great JS developer, but something like this should do the trick to convert OSGB back to WGS84

EDIT

oops.. you want the inverse transform.Just swap the two projections around in the proj4 call :)

var osgb = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs ';
var wgs84 = '+proj=longlat +datum=WGS84 +no_defs ';
proj4(osgb,wgs84,[200000,500000]);

You can get proj4 strings for any projection using the epsg.io website

  • proj.net, also available as nuget package, seems to do the trick. – cs0815 May 27 '16 at 8:16
7

There is a JavaScript from Convert between Latitude/Longitude & OS National Grid References which converts between easting/northings to lon/lat, which could be helpful.

It is also available in GitHub

  • Great. Will check asap. – cs0815 May 20 '16 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.