I never tested the following code how accurate it is... it was just a part of my dirty prototype... so would recommend test it...I followed the sample given on ProjNet
/// <summary>
/// Class that performs conversions using the ProjNet library.
/// </summary>
public class CoordinateConversion
{
/// <summary>
/// Function that converts UTM x,y to lat long.
/// </summary>
/// <param name="x">UTM x coordinate.</param>
/// <param name="y">UTM y coordinate.</param>
/// <param name="zone">The zone of the UTM.</param>
/// <param name="zoneisnorth">If Zone is north.</param>
/// <returns>The lat long value.</returns>
public static Point UTMtoLATLONG(double x, double y, int zone, bool zoneisnorth)
{
System.Windows.Point p = new System.Windows.Point(x, y);
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, zoneisnorth);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
IMathTransform test = trans.MathTransform.Inverse();
Point pxy = test.Transform(p);
return pxy;
}
/// <summary>
/// Lat long to UTM.
/// </summary>
/// <param name="latitude">The longitude value.</param>
/// <param name="longitude">The latitude value.</param>
/// <param name="zone">The UTM Zone.</param>
/// <param name="zoneisnorth">If the UTM zone is north.</param>
/// <returns>The UTM X and Y values.</returns>
public static Point LATLONGtoUTM(double latitude, double longitude, int zone, bool zoneisnorth)
{
System.Windows.Point pointGeo = new Point(longitude, latitude);
// Transform to UTM - Calculates UTM coordinates and zone
CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();
ICoordinateSystem wgs84geo = ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84;
int calculatedZone = (int)Math.Ceiling((pointGeo.X + 180) / 6);
ICoordinateSystem utm = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(calculatedZone, pointGeo.Y > 0);
ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(wgs84geo, utm);
Point pointUtm = trans.MathTransform.Transform(pointGeo);
// If calculated zone is not same as the supplied zone then convert the calculated UTM to the supplied UTM zone
if (calculatedZone != zone)
{
// The original UTM zone that the map is in
ICoordinateSystem utmto = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(zone, zoneisnorth);
// The UTM of calculated zone
ICoordinateSystem utmfrom = ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WGS84_UTM(calculatedZone, zoneisnorth);
trans = ctfac.CreateFromCoordinateSystems(utmfrom, utmto);
pointUtm = trans.MathTransform.Transform(pointUtm);
}
return pointUtm;
}
}