[GIS] Converting latitude and longitude into Northing and Easting

ccoordinate systemjquery

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 Easting, Northing for the postcode is:

389490
283880

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

Can anyone help?

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?


I finally got led to here which I can confirm works great.

Best Answer

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.