A class for calculating between Latitude/Longitude and Universal Transverse Mercator (UTM) coordinates which accurate maps like to use. It will reverse calculate as well.
You can set the class to use one of various datum ellipsoids such as WGS84, NAD83 and several others. The numbers programmed for each ellipsoid aren't the most accurate, but they can be easily modified to suit tastes. Currently, the error produced seems to be within a meter or so.
Here is the class: GPS.vb
Here's how to use it from Lat/Long in decimal coordinates (+ = N/E, - = S/W):
Here's how to use it in the opposite direction. You need 4 pieces of info, Northing (m), Easting (m), Zone and whether it's N or S hemisphere (default is North):Code:Dim lat As New GPS.Coordinate(myDecimalLatitude, GPS.CoordinateType.Latitude) Dim lng As New GPS.Coordinate(myDecimalLongitude, GPS.CoordinateType.Longitude) Dim utm As New GPS.UTM(lat, lng) Me.txtNorthing.Text = utm.Northing.ToString Me.txtEasting.Text = utm.Easting.ToString Me.txtZone.Text = utm.Zone.ToString Me.cmbHemisphere.Text = If(utm.UTMLatitudeHemisphere = GPS.UTMLat.North, "N", "S")
All equations and figures taken from an Excel spreadsheet example written by Professor Steven Dutch, of University of Wisconsin-Green Bay and is primarily ripped from the 1973 U. S. Army Technical Manual on the Universal Transverse Mercator Grid. I only take credit for turning it into a VB.NET 2008 ClassCode:Dim utm As New GPS.UTM(myNorthing, myEasting, myZone) utm.UTMLatitudeHemisphere = GPS.UTMLat.North Me.txtLatitude.Text = utm.Latitude.ToString Me.txtLongitude.Text = utm.Longitude.ToString
EDIT: I found a bug in the code that was flipping the sign of the Longitude during the UTM to Lat/Long conversion. New file uploaded with the fix.



the people who helped you and mark your forum RESOLVED when you're done! 
Reply With Quote


