Reputation: 23064
I have a bunch of Eastings/Northings coordinates, using the UTM convention as far as I can tell - so basically, they are cartesian coordinates - that I would like to convert to Latitude and Longitude.
Presumably NetTopologySuite can help me with this, but I can't find much documentation on it.
Anyone got some pointers to get me started?
Edit: The Eastings and Northings turned out to be, specifically, OS Grid Reference Eastings and Northings, the issues and conventions around which are discussed here.
Upvotes: 4
Views: 24127
Reputation: 330
This is a very old question but as it still came up in a search after 2 years I felt it's still worth providing an answer that may help others.
If you are able to use it the Ordnance Survey now provide a DLL (and an associated data file), or NTv2 file that can be used to perform the more accurate OSTN15 transformation. These are available under the BSD licence at : OSTN15 and OSGM15 for developers
This conversion will transform your co-ordinates to ETRS89 (approximately equivalent to WGS84 in Europe) and will be more accurate than the OSTN97/7 parameter helmert transformation mentioned in the answer from @codeulike.
Upvotes: 8
Reputation: 3526
The Proj.Net library is more likely to provide a simpler toolset for your needs.
You need to project from UTM (if it really is UTM - there A LOT of cartersian systems out there) to Geographic coordinate system. You will most likely need to find out the datum of your data as well. If you have have your data in a shapefile then look at the .prj file in a text editor - it will contain the projection information. Otherwise you need to go back to the data producer and ask them about the projection.
Upvotes: 3
Reputation: 2921
I know this is an old question but I have just been looking how to do this in C# and found this recently published article here.
The author has written a C# library available on nuget called GeoUK.
Install-Package GeoUK
With this library installed, to convert a easting/northing to a long/lat you would write a function like this:
static void Main(string[] args)
{
// downing street!
const double easting = 530046;
const double northing = 179914;
var result = ConvertEastNorthToLatLong(easting, northing);
Console.WriteLine("Lat: {0} Long: {1}", result.Latitude, result.Longitude);
var gmaps = string.Format("https://www.google.co.uk/maps/@{0},{1},17z", Math.Round(result.Latitude,6), Math.Round(result.Longitude,6));
}
static LatitudeLongitude ConvertEastNorthToLatLong( double easting, double northing )
{
// Convert to Cartesian
var cartesian = GeoUK.Convert.ToCartesian(new Airy1830(),
new BritishNationalGrid(),
new EastingNorthing(easting, northing));
//ETRS89 is effectively WGS84
var wgsCartesian = Transform.Osgb36ToEtrs89(cartesian);
var wgsLatLong = GeoUK.Convert.ToLatitudeLongitude(new Wgs84(), wgsCartesian);
return wgsLatLong;
}
}
This works for me and produces the result.
The article I mentioned earlier explains more in-depth. This might help someone else further down the line.
Upvotes: 4
Reputation: 1585
Check out CoordinateSharp on Nuget. It makes conversions SUPER easy.
UniversalTransverseMercator utm = new UniversalTransverseMercator("T", 32, 233434, 234234);
Coordinate c = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);
Your lat/long values are stored inside the Coordinate object for all lat/long formats (ie Minutes, Decimal Minutes, Seconds, etc...).
Upvotes: 0
Reputation: 23064
To answer my own question, the Eastings and Northings turned out to be Ordinance Survey (OS) ones, for which the conversion to Latitude and Longitude is quite well defined.
This very good page by Chris Veness discusses the main algorithm and common pitfalls. He presents a Javascript algorithm but I found a C# equivalent in this forum.
As Chris Veness points out, that algorithm gets you to Latitude and Longitude, but on the OSGB36 datum. Usually, you will then want to convert that to the WGS84/GRS80 datum more commonly used (otherwise you'll be up to 120m out, for UK locations). For that you need a Helmert transformation, as described by Chris here.
edit: Chris Veness's code is licensed under the GNU LGPL license.
Upvotes: 5