Convert eastings/northings to latitude/longitude using NetTopologySuite

后端 未结 5 1267
春和景丽
春和景丽 2020-12-29 17:17

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 conver

相关标签:
5条回答
  • 2020-12-29 17:40

    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.

    0 讨论(0)
  • 2020-12-29 17:48

    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...).

    0 讨论(0)
  • 2020-12-29 17:53

    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.

    0 讨论(0)
  • 2020-12-29 18:00

    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.

    0 讨论(0)
  • 2020-12-29 18:01

    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.

    0 讨论(0)
提交回复
热议问题