Question

I have a formula that I am using to calculate decimal degrees from gps coordinates.

GPS Coordinates: 3800.5825,N 08735.5417,W

Formula:

Private Function DMStoDD(ByVal toConvert As Double, ByVal Dir As String) As Double
    Dim DD As Double
    Dim deg As Double
    Dim min As Double
    Dim sec As Double
    deg = CDbl(toConvert.ToString.Substring(0, 2))
    min = CDbl(toConvert.ToString.Substring(2, 2))
    sec = CDbl(toConvert.ToString.Split(".")(1)) * 0.01
    DD = deg + (min / 60) + (sec / 3600)
    'Negative for West
    If Dir = "W" Then DD = DD * -1
    Return DD
End Function

Returns: 38.0161805555556 -87.5983805555556 (negative for west) The results are very close, but not quite right. I believe that they are just a little bit North West of where they actually should fall. I have searched and looked at a lot of different formulas, but from what I've read, I think that mine should be right. Thanks in advance for the help.

Was it helpful?

Solution

Your formula looks wrong, the part with the seconds! it tries a DMS to Degrees conversion. But you coordinates are in DM notation ( Degrees + Decimal minutes)

so you need a DM to DEG conversion.
08735.5417,W = 87deg 35.5147 minutes W

just do 87 + 35.5147/60, then multiply with -1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top