views:

1289

answers:

4

Hi I have the following UK postcode dy8 3xt and know that the latitude and longitude is:-

54.452772
-2.156082

I also know that the Eastings, Northings for the postcode is:-

389490
283880

However I am struggling to find the equation that converts lat/long to northings and Eastings, I would prefer to have the equation in both in jScript and c# (I am being greedy)!

Can anyone help?

EDIT Thanks for your help so far guys, I am starting to learn something here esp. the terminology...

Some more info, if you click on this link you can see the results I am looking for. The postcode I entered projects to lat/lng using WG S84 and the grid ref projects to OSGB. So my question is how is this done?

WHAT I LEARNT

Thanks to all that answered, I finally got led to here which I can confirm works great

+1  A: 

Here's a reference.

John at CashCommons
Crikey, that spreadsheet looks scary, I was hoping for x = y * 2!
Rippo
@rippo A simple approximation algorithm could probably be obtained by taking the average values for each of those various equatorial / polar radii and flattening values, but an approximation would be all it is. The earth is neither a perfect sphere nor even radially symmetrical at the levels of precision implied by the number of significant digits you use in your example.
Jherico
Viewing the source for Dan's page should be what you're after for the JS part.
John at CashCommons
@john I have tried dans suggestion but cannot get the results that I expect, Obviously I do not understand what it is I am asking for but I do know the numbers I gave are correct.
Rippo
@all have posted an edit with a link showing the desired results and the projection used
Rippo
+1  A: 

Is this for UTM zone northing/eastings? I wrote a utility for that in javascript:

http://cambertx.com/utm/

Dan
Nice work! Why no AdSense on that page? ;)
John at CashCommons
Excellant, will have a look at this.
Rippo
@dan I have tried this but cannot get the expected results. Obviously there is something that I do not understand.
Rippo
This is the original code I used to get the idea: http://home.hiwaay.net/~taylorc/toolbox/geography/geoutm.htmlI had to modify the code for my company, but it's generally the same idea.@John: Probably because my corporate hq would have a fit if they saw ads on their site.
Dan
Rippo, I think you need to establish which type of projection those numbers are coming from. The "easting and northing" numbers are the result of the geographic coordinates being converted to a certain type of projection standard. They all have different algorithms, so I just threw out UTM because that's what I assumed you're using. Figure out the projection method, and then we can find the correct formula for you. UTM usually has a certain zone number associated with the part of the globe you are working with, so if you don't have that zone number, it's probably not utm.
Dan
@Dan Ahh good reason ... thought that was your own website.
John at CashCommons
@all have posted an edit with a link showing the desired results and the projection used
Rippo
+3  A: 

Edit - Update with OSGB36 specific information.

Well, the good news is that the target projection is OSGB36, which is a well known and standardized projection. The bad news is that GIS programming is still really difficult :)

There are a set of parameters that need to be defined, and mathematical operations applied to those parameters, to succesfully project lat/long to grids. Fortunately, there are databases of parameters for the former, and libraries for the latter. proj.4, which I mentioned earlier, is one of the standard libraries. There are also ports of proj.4 to other languages, including JavaScript, which is hopefully close enough to jScript for your purposes. The port is proj4js.

The other thing you need to know is the EPSG number for your coordinate systems. OSGB36 is EPSG:6277. The EPSG is an oil-industry (I think) created body that collected lots of locally defined projections and documented them. The database is now openly maintained, and GIS libraries can use their definitions.

Previous info

Your easting/northing numbers may be in the British national grid system.

I gave an answer to another GIS related question that includes links to proj.4, which is one of the standard libraries for converting between lat/long and easting/northing (the forward calculation is called projection in the GIS world). I've never used it for the conversion you're looking for, but the software is well-documented and comes with conversion definitions for lots of projections.

mtrw
@mtrw have posted an edit with a link showing the desired results and the projection used
Rippo
Thanks for your input, I have learnt alot from this... See my answer
Rippo
@Rippo - Glad to have helped! GIS is really interesting. I recently left the job where I dabbled in that area, and I miss it a bit.
mtrw
For a C# answer check out this question http://stackoverflow.com/questions/1867950/is-there-a-free-net-library-to-convert-osgb36-to-wgs84
MarkJ
+2  A: 

The C# part of this question is a duplicate of Is there a free .Net library to convert OSGB36 to WGS84? The answers list two free libraries.

MarkJ