I need to convert UTM to DMS. For example: x 6518585.31 y 13343143.32 -> degrees minutes seconds.
People refer to this library esri.arcgis.defensesolutions.dll, but I can't find where to download it.
I need to convert UTM to DMS. For example: x 6518585.31 y 13343143.32 -> degrees minutes seconds.
People refer to this library esri.arcgis.defensesolutions.dll, but I can't find where to download it.
Try the ArcGIS Runtime SDK for .NET. You can download and use it at no cost for coordinate conversion. Sample code is available, but here's the relevant code for what you need to do. You can use http://spatialreference.org/ref/ to find the WKID for your UTM zone; I'm using 32642
, which is the WKID for UTM zone 42N based on WGS84.
var utmSpatialReferenceWkid = 32642;//UTM zone 42N based on WGS84
var pointUtm = new MapPoint(6518585.31, 13343143.32, utmSpatialReferenceWkid);
var pointLonLat = GeometryEngine.Project(pointUtm, SpatialReference.Wgs84);
var longitude = pointLonLat.X;
var latitude = pointLonLat.Y;
The defensesolutions DLL you mentioned is older technology, and you need an ArcGIS Desktop or Engine license to use it, which incurs a cost. Use ArcGIS Runtime instead.
coordinate system "Meters" to "Degrees Minutes Seconds"
ISpatialReferenceFactory srEnv = new SpatialReferenceEnvironmentClass();
var wgsIn = srEnv.CreateESRISpatialReferenceFromPRJFile(@"C:\111.prj");
var wgsOut = srEnv.CreateESRISpatialReferenceFromPRJFile(@"C:\222.prj");
var point = new PointClass();
point.PutCoords(3304534.9530999996, 6859385.3066000007);
point.Project(wgsIn);
var dmsCoord = new DMSCoordinate
{
Precision = esriCoordinatePrecision.esriCPOneMeter,
InputSpatialReference = wgsIn,
OutputSpatialReference = wgsOut,
Point = point
};
var dsd = dmsCoord.String;
dmsCoord.String Returns incorrect coordinates
You can use CoordinateSharp for exactly this.
Example
UniversalTransverseMercator utm = new UniversalTransverseMercator("T", 32, 233434, 234234);
Coordinate c = UniversalTransverseMercator.ConvertUTMtoLatLong(utm);
Console.WriteLine(c); //Outputs DMS formatted coordinate by default.
You can also access individual lat/long properties within the Coordinate
object.