Possible Duplicate:
Easting northing to latitude longitude
I have many Northing/Easting data in a database (for example: n 15217, e 88911
) and I need convert it to Lat/long
with T-SQL.
How I can do it?
Possible Duplicate:
Easting northing to latitude longitude
I have many Northing/Easting data in a database (for example: n 15217, e 88911
) and I need convert it to Lat/long
with T-SQL.
How I can do it?
There is an Open Source dll library here (geocoordconversion) that can convert eastings/northings to lat/lon. So you could knock something up to use that for the raw conversion.
Alternatively, what might be useful, I have a project on GitHub that uses this DLL to import the full Ordnance Survey postcode dataset into SQL Server, converting the eastings/northings to lat/lon as it goes. This is available as a command-line executable. If this aligns well with what you're wanting, then you might be able to use that. Or at least, there is code to highlight how to use the DLL to perform the conversion.
Update From my project, .NET snippet using the dll to convert to lat/lon:
/// <summary>
/// Converts northing and easting coordinates into Longitude/Latitude coordinates in the WGS84 coordinate system.
/// </summary>
/// <param name="northing">northing coordinate</param>
/// <param name="easting">easting coordinate</param>
/// <returns>converted coordinates</returns>
protected PolarGeoCoordinate ConvertToLonLat(double northing, double easting)
{
// Use GeoCoordConversion DLL to convert the Eastings & Northings to Lon/Lat
// coordinates in the WGS84 system. The DLL was pulled from: http://code.google.com/p/geocoordconversion/
// and is available under the GNU General Public License v3: http://www.gnu.org/licenses/gpl.html
GridReference gridRef = new GridReference((long)easting, (long)northing);
PolarGeoCoordinate polarCoord = GridReference.ChangeToPolarGeo(gridRef);
return PolarGeoCoordinate.ChangeCoordinateSystem(polarCoord, CoordinateSystems.WGS84);
}
If you see this page is shows the algorithm you can apply to change this UTM format change them. There is a sample spread sheet on the page you download and have a look at the calculations. I suspect it should be quite easy to turn grab the look up tables and use them join to your data.