-
1 Attachment(s)
GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
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: Attachment 65934
Here's how to use it from Lat/Long in decimal coordinates (+ = N/E, - = S/W):
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")
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 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
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 Class :)
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.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi i have a UTM coordinates like this x = 520825 , y = 2869270
How i can convert this coordinates to Latitude/Longitude? , my zone is 14 and Hemisphere is North.
Regards
Isaias
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
That would be the second example I posted above. Sorry, I noticed the variable names were still listed as "Latitude" and "Longitude" and not "Northing" and "Easting".
But just make a new object, give it the 4 peices of information and read the latitude and longitude from it. It does the conversion as you change the data.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
i get 'Truncate' is not a member of 'System.Math'
any ideas??
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi,
I’m working with data downloaded from a gps device, using vb2008 express I can open a file, load this into an array and extract the required lat long co-ordinates. I now need to convert these to utm so that I can do some basic trig to calculate distances.
Your class seems ideal for the next step but as I'm only at the stage of creating basic programs I need some help to get the data from the array processed by the class and extract the utm data at the end.
I’m just doing this for fun, in connection with my other hobby, paragliding, any help or direction as to where to get more info would be greatly appreciated.
Thanks
Chris
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Get your numbers from the array. You should have a Lat and a Long number. Then just follow my example above. Put those numbers in the myDecimalLatitude and myDecimalLongitude spots in that example. For example, if you had Lat: 51.6702014 Long: -76.1103928, you'd do this (remember, negative coordinates indicate South latitudes and West longitudes):
Code:
Dim myDecimalLatitude = 51.6702014
Dim myDecimalLongitude = -76.1103928
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)
'The results are instantly calculated and available:
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")
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
thank you for your help with this, I still have some work to do on processing the data form the array but I am making progress with this. I can now see how the class works and think it is brilliant. I have tested the accuracy, at home here in Northumberland, UK, it is accurate to under 1 meter.
Again, many thanks for your help.
Chris
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
I'd say less than 1 meter is pretty good for most needs. :)
I think this class can be implemented a little better, but I honestly haven't had the time to do it.
-
1 Attachment(s)
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
what do I have to import o get GPS working?
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Quote:
Originally Posted by
kiwis
what do I have to import o get GPS working?
Have you added the GPS.vb source file to your project? If not then how is the project supposed to know the GPS class exists?
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
I thought I had but clearly not.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
What errors are you getting exactly, because looking at your screenshot, it looks like you have the GPS class on the tab behind the Form1 object.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Quote:
Originally Posted by
Jenner
What errors are you getting exactly, because looking at your screenshot, it looks like you have the GPS class on the tab behind the Form1 object.
Having the file open in VS doesn't mean it's part of the project. If you already have VS open and you download a VB file it will be opened in the same VS window, but it's not added to the project automatically.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
True, hadn't thought of that. You can always "view" .vb files in the editor, it doesn't mean they've been added to your solution. He copy-pasted my code example in the global area of his class object as well. It needs to be inside a subroutine or a function block like all other non-defining code.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
How can I place these coordinates on a map?
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
You just need a proper map that has UTM alignment information from what I understand. It'll have a grid of Northing and Easting on it with UTM coordinates; as opposed to a map with Lat and Long projections.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
I can not seem to find a world map :-(
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
The other option is I convert the northing value into pixels. So if there is 80° S latitude and 84° N then there is 164 in total start from the bottom. If my map was 492px high and I wanted to find something at 76S I would go 12 pixels high. 3 times.
Only problem is this would be way out unless I made the 164 the true value as such, how many meters is it between 80 and 79??
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Right, at this point, your problem seems to be one of conversion between real-world coordinates and what is displayed on the screen.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Yes. I want to be able to convert long and lat coord's onto a world map displayed in front of me on my screen
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
I downloaded the file GPS.VB and loaded into VB.net. Using UTM to Lat/Lon, the Longitude that is returned is always 0.
You mentioned in one of the post that the code had an error. Could you Please post the corrected code?
Thanks
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
The error was fixed and posted long ago. The only error found in the code that has not been fixed in the download is an insignificant math error in the arc second calculation that makes the number off at most 1 inch at the equator. If you want to fix that, then just change this line in the object:
Code:
Dim e0 As Double = (315 * a * n ^ 4 / 51) * (1 - n)
to this:
Code:
Dim e0 As Double = (315 * a * n ^ 4 / 512) * (1 - n)
Are you instancing the class properly? Are you specifying the zone, northing, easting and hemisphere? You need all four pieces of information to convert from UTM to Lat/Long. See my example above.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Thanks for the reply:
I am basicly taking a lat/lon and passing it to the LL To UTM converter then taking that result and passing it to the UTM to LL Converter.
Here is what I do:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
LLToUTM(31.5, 91.5)
End Sub
Public Sub LLToUTM(ByVal myDecimalLatitude As Single, ByVal myDecimalLongitude As Single)
Dim txtNorthing As String
Dim txtEasting As String
Dim txtzone As String
Dim cmbhemisphere As String
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)
txtNorthing = utm.Northing.ToString '<<-This is 3485991.16655783
txtEasting = utm.Easting.ToString '<<-This is 357546.073706798
txtzone = utm.Zone.ToString ' <<-This is 46
cmbhemisphere = If(utm.UTMLatitudeHemisphere = GPS.UTMLat.North, "N", "S") 'N
TUMToLL(utm.Northing, utm.Easting, utm.UTMLatitudeHemisphere)
End Sub
Public Sub TUMToLL(ByVal MyNorthing As Single, ByVal myEasting As Single, ByVal myzone As String)
Dim txtLatitude As String
Dim txtLongitude As String
Dim utm As New GPS.UTM(myNorthing, myEasting, myZone)
utm.UTMLatitudeHemisphere = GPS.UTMLat.North
txtLatitude = utm.Latitude.ToString '<<-This is 31° 29' 59.989" North
txtLongitude = utm.Longitude.ToString '<<-This is '0° 0' 0.000" North
End Sub
The Longitue is returning a NORTH value.
I downloaded the GPS.VB from the top if this post.
Thanks again
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Well....as soon as i sent the previous reply...I saw my error. I sent the wrong parameter for the ZONE.
Thanks It works GREAT
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Jenner
Your class works great...Thanks
But, I do have a question for you.
Since the Easting and Northing returns values from their ZONES. How can I calculate a value such as distance from two points in two different Zones?
Thanks again
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
The only way would be to convert the WGS coordinates to Lat/Long and perform a Great Circle calculation to get the arc length between them.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi Gary,
You could use the Haversine formula, see http://en.wikipedia.org/wiki/Haversine_formula
This calculates distance between two lat/long positions based on the earth as a perfect sphere; it gives an accuracy of about 0.3% and is not too difficult to understand and code. The more complex Versine formula uses a model that can be based on a map datum such as wgs84 and is more accurate - but I couldn’t figure out how to code this, perhaps someone more able might have a go.
cheers
chris
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi
how to get my zone value?
if i have those values
lat=49.568511
lon=27.104216
what will be the code to convert them to N,E ?
i try this code
http://www.vbforums.com/showpost.php...59&postcount=1
but it gives me wrong values !!
what will be te right code?
thanks in advance.
-
1 Attachment(s)
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
If it gives you the wrong values, then you're using it wrong.
It works perfectly:
Attachment 76572
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
thanks for reply
yea right this result also for me
Northing=5490662.87262606
Easting=507535.487639871
Zone=35
Hemisphere=N
BUT when im in Google earth and i convert from lat and Lon to N,E from options it gives me
27° 6.253 N
49° 34.111 E
so how to make it like Google result
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi,
thanks for you great class! But it doesn´t work for me...
I´ve
UTM in Format
32337666
5656482
32N
and I need to get WGS84 in this format
50.94082111
6.68391562 !
But when I start this code
Code:
Dim utm As New GPS.UTM(5656482.0, 32337666.0, 32)
utm.UTMLatitudeHemisphere = GPS.UTMLat.North
Label6.Text = utm.Latitude.ToString
Label7.Text = utm.Longitude.ToString
I get
0° 0' 0,000" North
0° 0' 0,000" North
as result!!!
Greets
Byte
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
That's because your data is bad. How do you have numbers in the 32 million and 5 million range? If you put your numbers in any online converter you'll see some crazy funny-number results like a Lat of 520 degrees.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi,
I get the data from a address-database!
What do you mean, my data is crazy?
Do you think it isn´t UTM ?
ATENTION:
on Site http://www.ipf.uni-karlsruhe.de/cgi-bin/trafo.tcl
UTM 32 WGS84 -> Gauss-Krueger Nr.2/6 Grad (West-D)
WORKS FINE !!!!!! But theres no source
Need help, please....
Greets
Byte
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Alright, I figured it out. This is such a stupid notation.
Take your data:
32337666
5656482
32N
The first number is a combination of the Zone and the Easting: 32337666 You want to remove the Zone numbers before converting. They're always the first two. This is apparently a standard notation used by the Germans.
So, put THESE numbers into the converter:
Northing: 5656482
Easting: 337666
Zone: 32
Hemisphere: N
Of course, you can always edit the converter to accept that notation as the standard input and strip the zone off then.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Any chance you have the code for C#. I tried a bunch of converters but code would not compile. What imports ("using" in C# to I need).
Cam
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
It's really simplistic code from a conversion standpoint. There's no events or event handlers, no fancy VB tricks. Just some basic constructors and math.
Of course, you could always take up VB.NET. ;)
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hello Jenner,
I finally manged to get it to compile in C#. Not as straightforward as I had hoped.
Another thing that I noticed is the follwong line:
double sin1 = Math.PI / (180 * 3600); warning CS0219: The variable 'sin1' is assigned but its value is never used.
Is this important or maybe it is just for testing?
Cam
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
It doesn't surprise me. The equation set I used was simplified for slide-rule and table calculation and some terms were used in more than one figuring.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
After compiling and using the code in C# I have tried to convert the coordinates from a user click on my Web Mapping Application. My coordinates are in UTM Zone 10.
Sample coords are: 510472 E and 5440699 N.
This gives results of 48.97625305 and -122.8564619 which is many miles to the south of where I want. I want to be able to zoom to google maps based on the user click.
maybe something happened when I convert to C#.
Jenner using the vb code what lat/long do you get for the above coords.
Cameron
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
I get: 49.119 lat, -122.856 long (assuming north hemisphere)
Yea, check the math in the latitude conversion.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi
i have these coordinates N53200,E70300 from a map and this place in saudi arabia
and i want to convert to it corresponding lat and lon (lat=27 13.0947 lon=49 539406)
how?
i try the above code but it gives me wrong value
thanks in advance.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
which is many miles to the south of where I want. I want to be able to zoom to google maps based on the user click.maybe something happened when I convert to C#.
-
UTM to decimal degree
In sample 2 from your first post, how do I return decimal degree?
Regds
Inge
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
any idea how to convert those coordinates N53200,E70300
to degrees? because i don't know what are these coordinates are?
thanks in advance.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Please verify all coordinates with this (or any other) online conversion engine: http://www.rcn.montana.edu/resources...ordinates.aspx
I've verified this class many times with the example one I gave and several others, and it's been extremely accurate. If you don't know what kind of coordinate data you have, then I suggest reviewing your own data and researching various coordinate systems on Google.
Looking over the code, you should easily find where it generates the decimal values of Latitude and Longitude before converting it to the output strings.
Finally, no, I don't know what global coordinate system Google Maps uses or if it works/doesn't work with this class. Once again, it's something you'll have to research with Google. Like the title of this post says, this class converts between Lat/Long and various UTM Coordinates such as WGS84. If you don't understand what every word in that last sentence means, then you've got some research to do. :)
Converting map coordinates is far-far trickier than most people think. There are a LOT of coordinate/mapping standards out there; some global, some outdated, many local or country-specific. Some are even patch-work which means depending on where you are, the computational data changes (such as NAD27). Know what you're working with before posting please.
Thanks you.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hello Jenner,
I am new to coordinate conversion, but was googling around and found your class and it is exactly what I need. I am following your examples, using a Lat/Long of 35.97327766/-85.96502471 and trying to convert it to NAD83 UTM (TN Zone 4100). I am getting the values easting: 593312.90865883883 and northing: 3981479.7292554607, but the values I have supplied to me by a flight client for the easting/northing are 1978849.094,596951.126. Any help or expertise you could provide would be greatly appreciated.
Thank you.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Can this be used to override zones? By that I mean, can I force it to calculate the Easting/Northing in a specific zone?
Thanks,
John
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hello Jenner,
(I hope you are still paying attention to this thread)
I am trying to use the class you built in VB in my project. However, I am having problems with coordinates in the southern hemisphere.
I have created a C# test class based on the Excel spreadsheet from http://www.uwgb.edu/dutchs/UsefulDat...ertUTMNoOZ.HTM . I have put the file on GitHub - it is available on https://github.com/jlundstocholm/Coo...Transformation .
All coordinates in the Northern hemissphere are calculated correctly, but all coordinates in South fail. As an example, the coordiates
Northern: 3000000
Eastern: 430000
Hemisphere: South
Zone: 28
Is supposed (from the spreadsheet as well at the test page on http://www.rcn.montana.edu/resources...&n=3000000&h=S ) to be
Code:
Longitude: 15° 42' 22,616" West
Latitude: 27° 8' 45.503" South
But your class yields the result
Code:
Longitude: {16° 23' 16,314" West
Latitude: 63° 7' 21,179" South
I have looked thru the code and as far as I can see, it pretty much mimics the formulas in the spreadsheet.
Do you have an idea of what I am doing wrong?
And also: have you thought about putting an Open Source license to your class like Apache, BSD or similar? It would make it easier to reuse in projects.
Thank you,
:-)
/Jesper Lund Stocholm
Copenhagen, Denmark
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hello Jenner.
I need to convert Lat/Lon coordinates to MGRS and vice-versa ina VB. Net web application (VS2010).
Could you help?
T.I.A.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
MGRS is based on UTM and isn't too hard to convert between the two. Just Google "MGRS to UTM formula" and you should find something you can use. Thus, you can use this class to convert from Lat/Long to UTM and then from UTM to MGRS and back.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Quote:
Originally Posted by
jvonbokel
Can this be used to override zones? By that I mean, can I force it to calculate the Easting/Northing in a specific zone?
Thanks,
John
The GPS.vb was just what I've been looking for. It works great.:bigyello:
But I also need to "force" zones. In Norway we only use UTM zone 32,33 and 35. We skip 31, 34 and 36.
Can anyone give me a hint of what to do?
Thanks.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
You can probably change the math routine to skip certain zones and calculate to adjacent zones. It sounds like Norway uses a local variant of general purpose UTM. Several countries do apparently, there are dozens and dozens of "local" systems that are anywhere from small tweaks to UTM to complete hybrids with local patch transforms.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Quote:
Originally Posted by
Jenner
You can probably change the math routine to skip certain zones and calculate to adjacent zones. It sounds like Norway uses a local variant of general purpose UTM. Several countries do apparently, there are dozens and dozens of "local" systems that are anywhere from small tweaks to UTM to complete hybrids with local patch transforms.
I could substitue GetZoneCM() with 9 (centermeridian of zone 32). that would probably do the trick. Btw all of southern Norway is in zone 32, although the western part should be in zone 31.
http://en.wikipedia.org/wiki/File:LA...-UTM-zones.png
Anyway thnx :)
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hi Jenner - I really appreciate the effort you have invested to make this code available and I accept that it is accurate, so I also accept any error is my error but hoping to prevail on your good nature (what a creep, eh)
OK, although I'm new to this vb .Net lark, I think I have installed the code OK on the grounds that it doesn't crash and it doesn't complain and it does something.
vb Code:
Dim utm As New GPS.UTM(340374, 366857, 30)
utm.UTMLatitudeHemisphere = GPS.UTMLat.North
utm.Datum = GPS.UTMDatum.WGS84
txtLatitude = utm.Latitude.ToString
txtLongitude = utm.Longitude.ToString
MsgBox(txtLatitude & "," & txtLongitude)
The txtlatitude variable returned is 3 degrees, 4 minutes and 43.550 seconds
the txtLongitude variable returned is 4 degrees, 11 minutes and 53.319 seconds
but if I use an external website thus
http://rcn.montana.edu/resources/too...4&n=366858&h=N
I get
Latitude: 3° 19' 4.776" N
Longitude: 4° 26' 12.338" W
I don't understand how I have made an error. Can you help?
A second question, if I may - can the code return Degree Decimal format results?
Thanks in anticipation
Tim
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Hello TimHaydnJones,
Welcome to the forums!
Just a quick note...
When you are posting code into the forum, can you please remember to surround it in [code][/code] or [HIGHLIGHT=vb][/highlight] tags? It makes it a lot easier to read. I have done this for you in your above post.
Gary
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Quote:
Originally Posted by
TimHaydnJones
Hi Jenner - I really appreciate the effort you have invested to make this code available and I accept that it is accurate, so I also accept any error is my error but hoping to prevail on your good nature (what a creep, eh)
OK, although I'm new to this vb .Net lark, I think I have installed the code OK on the grounds that it doesn't crash and it doesn't complain and it does something.
vb Code:
Dim utm As New GPS.UTM(340374, 366857, 30)
utm.UTMLatitudeHemisphere = GPS.UTMLat.North
utm.Datum = GPS.UTMDatum.WGS84
txtLatitude = utm.Latitude.ToString
txtLongitude = utm.Longitude.ToString
MsgBox(txtLatitude & "," & txtLongitude)
The txtlatitude variable returned is 3 degrees, 4 minutes and 43.550 seconds
the txtLongitude variable returned is 4 degrees, 11 minutes and 53.319 seconds
but if I use an external website thus
[url]http://rcn.montana.edu/resources/tools/coordinates.aspx?nav=11&c=UTM&md=83&mdt=NAD83/WGS84&z=30&e=340374&n=366858&h=N
I get
Latitude: 3° 19' 4.776" N
Longitude: 4° 26' 12.338" W
I don't understand how I have made an error. Can you help?
A second question, if I may - can the code return Degree Decimal format results?
Thanks in anticipation
Tim
Your Northing and Easting are reversed. In my tool, you use the format:
GPS.UTM(Northing, Easting, Zone)
GPS.UTM(340374, 366857, 30)
but in the web tool, your link shows:
http://rcn.montana.edu/resources/tools/coordinates.aspx?nav=11&c=UTM&md=83&mdt=NAD83/WGS84&z=30&e=340374&n=366858&h=N
If you flip the two on the web tool, you'll see you get a result that matches my tool and vice-versa. :)
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
DOH! - do I feel sheepish or what!
Moving onto my next issue, if I may - Is there a way I can pass in 6x6 digit UK Eastings and Northings, based on the Ordnance Survey National Grid (OSNG)?
The OSNG coordinates (Eastings) 329636, (Northings) 407288 relate to a lat/long of 53.5575437399072, -3.06531429290771 but convert back to a
UTM Easting of 495673 and a UTM Northing of 5934298 (WGS84 Zone 30).
(Reading some documentation from the Ordnance Survey, I guess this is something to do with the fact that the OSNG origin is at Lat 49 degrees North and Long 2 degrees West, which means that my OSNG Northings are too small and (it seems) I can't pass them into your code in their native form)
So, I understand that I can use your code to translate from the UTM to Lat/Long and vice versa but can I use it to convert my 6x6 OSNG co-ordinate to Lat/Long?
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
As written, I'm afraid not. Every local/country grid has it's own sets of peculiarities that must be programmed around. I mean, it's certainly possible to write a conversion, but I'm afraid I'm not that good at math to undertake such a task. :o
Back when I found the formulations and decided to write this class up, I looked into writing up routines to convert into the United States system as well... but researching the problem showed me just how immensely complex that would have been since almost every state in our country has it's own "local grid data" with table-loads of conversions required to stitch it all together into the monstrosity known as NAD83.
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
Thanks for a rapid response, Jenner and thanks again for the code.
Oh, and by the way, if you think your Maths is questionable, you should see mine:cry:
regards
Tim
-
Re: GPS Class that maps Lat/Long to UTM Coordinates (WGS84 and others)
A word of warning - as you might have gathered from some of the posts in this thread, porting this class to C# using an online converter will screw some things up. My latitude was off by about 10 miles. If I ever get a C# version running, I will edit this post with a link to the code.