Here is a VB function I have from an excel program that converts UTM to
Lat/Long and vice versa. It should work in Access, but I haven't tried.
I'm not sure how it works, haven't gone through the math, but it works. You
do need to know some information in order for this to work. You need to
know at least 1 lat and long point in the zone. It can be any point, as
longs as its within the zone. These are passed to the first 2 parameters of
the function.
Good Luck.
Kelvin
' UTM to (Lat,Long), and (Lat,Long) to UTM Module
' Kenneth M. Cruikshank
' Department of Geology
' Portland State University
' Portland, OR 97207-0751
' This is a quick hack ... it needs some cleaning up
' From: Newton, G.D., 1985. Computer programs for common map projections.
' United States Geological Survey Bulletin 1542
' Force all variables to be explicity defined
Option Explicit
Const Radians2Degrees = (180# / 3.14159)
Const Degrees2Radians = (3.14159 / 180#)
Public A As Double
Public B As Double
Public M0 As Double
Public E2 As Double
Public EPS As Double
Public A0 As Double
Public A1 As Double
Public A2 As Double
Public Err As Double
Public Phi0 As Double
Public Lam0 As Double
Public Y0 As Double ' Defined in Function Sinv()
Function UTM_to_LatLong(BaseLat As Double, Lam As Double, x As Double, y As
Double) As Variant
Dim AA0 As Double
Dim AA1 As Double
Dim AA2 As Double
Dim AA3 As Double
Dim AA4 As Double
Dim AE As Double
Dim C As Double
Dim CentralMeridian As Double
Dim E4 As Double
Dim E6 As Double
Dim E8 As Double
Dim i As Integer
Dim Izone As Integer
Dim Latitude As Double
Dim Longtitude As Double
Dim N As Double
Dim N2 As Double
Dim N4 As Double
Dim N6 As Double
Dim N8 As Double
Dim Oldy As Double
Dim Phi As Double
Dim S As Double
Dim T As Double
Dim T2 As Double
Dim T3 As Double
Dim T4 As Double
Dim T5 As Double
Dim T6 As Double
A = 6378206.4
B = 6356584.8
M0 = 0.9996
E2 = (A * A - B * B) / (A * A)
EPS = (A * A - B * B) / (B * B)
E4 = E2 * E2
E6 = E4 * E2
E8 = E6 * E2
AE = A * (1# - E2)
A0 = AE * (1 + (3 / 4) * E2 + (45 / 64) * E4 + (175 / 256) * E6 + (11025
/ 16384) * E8)
A1 = -AE / 2 * ((3 / 4) * E2 + (15 / 16) * E4 + (525 / 512) * E6 + (2205
/ 2048) * E8)
A2 = AE / 4 * ((15 / 64) * E4 + (105 / 256) * E6 + (2205 / 4096) * E8)
Err = -AE / 6 * ((35 / 512) * E6 + (315 / 2048) * E8)
Phi0 = BaseLat * Degrees2Radians
' Following give UTM Zone number and Central Meridian
Izone = Int((180 - Lam) / 6 + 1)
Lam0 = (183# - (6 * Izone)) * Degrees2Radians
CentralMeridian = Lam0 * Radians2Degrees
x = (x - 500000#) / M0
y = y / M0
Phi = Sinv(y, Phi0)
Oldy = y
For i = 1 To 10
Phi = Sinv(y, Phi)
If (Oldy = Y0) Then Exit For
Oldy = Y0
Next
S = Sin(Phi)
C = Cos(Phi)
T = S / C
T2 = T * T
N2 = EPS * C * C
N = A / Sqr(1# - E2 * S * S)
AA0 = x / N
AA1 = AA0 ^ 3 * (1# + 2# * T2 + N2) / 6#
AA2 = AA0 ^ 5 * (5# + 28# * T2 + 24# * T2 * T2 + 6# * N2 + 8# * T2 * N2)
/ 120#
Longtitude = Lam0 - (1# / C) * (AA0 - AA1 + AA2)
Longtitude = Application.Degrees(Longtitude)
T3 = T * T2
T4 = T * T3
T5 = T * T4
T6 = T * T5
N4 = N2 * N2
N6 = N4 * N2
N8 = N6 * N2
AA1 = T * (1# + N2) * AA0 * AA0
AA2 = T * (1# + N2) * AA0 ^ 4 * (5# + 3# * T2 + N2 - 4# * N4 - 9# * N2 *
T2)
AA3 = T * (1# + N2) * AA0 ^ 6 * (61# + 90# * T2 + 46# * N2 + 45 * T4 _
- 252# * T2 * N2 _
- 3# * N4 + 100# * N6 - 66# * T2 * N4 - 90# * T4 * N2 + 88# * N8 _
+ 255# * T4 * N4 + 84# * T2 * N6 - 192 * T2 * N8)
AA4 = T * (1# + N2) * AA0 ^ 8 * (1385# + 3633# * T2 + 4095# * T4 + 1575#
* T6)
Latitude = Phi - AA1 / 2# + AA2 / 24# - AA3 / 720# + AA4 / 40320#
Latitude = Application.Degrees(Latitude)
UTM_to_LatLong = Array(Latitude, Longtitude)
End Function
Function LatLong_to_UTM(BaseLat As Double, Lam As Double, Lat As Double, Lon
As Double) As Variant
Dim AA0 As Double
Dim AA1 As Double
Dim AA2 As Double
Dim AA3 As Double
Dim AE As Double
Dim B0 As Double
Dim B1 As Double
Dim B2 As Double
Dim B3 As Double
Dim B4 As Double
Dim C As Double
Dim C2 As Double
Dim C3 As Double
Dim C4 As Double
Dim C5 As Double
Dim C6 As Double
Dim C7 As Double
Dim CentralMeridian As Double
Dim D As Double
Dim D2 As Double
Dim D3 As Double
Dim D4 As Double
Dim D5 As Double
Dim D6 As Double
Dim D7 As Double
Dim D8 As Double
Dim E4 As Double
Dim E6 As Double
Dim E8 As Double
Dim Izone As Integer
Dim N As Double
Dim N2 As Double
Dim N4 As Double
Dim S As Double
Dim T As Double
Dim T2 As Double
Dim T4 As Double
Dim T6 As Double
Dim x As Double
Dim y As Double
A = 6378206.4
B = 6356584.8
M0 = 0.9996
E2 = (A * A - B * B) / (A * A)
EPS = (A * A - B * B) / (B * B)
E4 = E2 * E2
E6 = E4 * E2
E8 = E6 * E2
AE = A * (1# - E2)
A0 = AE * (1 + (3 / 4) * E2 + (45 / 64) * E4 + (175 / 256) * E6 + (11025
/ 16384) * E8)
A1 = -AE / 2 * ((3 / 4) * E2 + (15 / 16) * E4 + (525 / 512) * E6 + (2205
/ 2048) * E8)
A2 = AE / 4 * ((15 / 64) * E4 + (105 / 256) * E6 + (2205 / 4096) * E8)
Err = -AE / 6 * ((35 / 512) * E6 + (315 / 2048) * E8)
Phi0 = Application.Radians(BaseLat)
Izone = Int((180 - Lam) / 6 + 1)
Lam0 = Application.Radians(183# - (6 * Izone))
CentralMeridian = Application.Degrees(Lam0)
D = Lam0 - Application.Radians(Lon)
D2 = D * D
D3 = D2 * D
D4 = D3 * D
D5 = D4 * D
D6 = D5 * D
D7 = D6 * D
D8 = D7 * D
S = Sin(Application.Radians(Lat))
C = Cos(Application.Radians(Lat))
T = S / C
T2 = T * T
T4 = T2 * T2
T6 = T4 * T2
C2 = C * C
C3 = C2 * C
C4 = C3 * C
C5 = C4 * C
C6 = C5 * C
C7 = C6 * C
N2 = EPS * C * C
N4 = N2 * N2
N = A / Sqr(1# - E2 * S * S)
AA0 = N * C
AA1 = N * C3 * (1 - T2 + N2)
AA2 = N * C5 * (5 - 18 * T2 + T4 + 14 * N2 - 58 * T2 * N2)
AA3 = N * S * C7 * (61 - 479 * T2 + 179 * T4 - T6)
B0 = ss(Lat)
B1 = N * S * C
B2 = N * S * C3 * (5 - T2 + 9 * N2 + 4 * N4)
B3 = N * S * C5 * (61 - 58 * T2 + T4 + 270 * N2 - 33 * T2 * N2)
B4 = N * S * C7 * (1385 - 3111 * T2 + 543 * T4 - T6)
x = M0 * (AA0 * D + AA1 * D3 / 6 + AA2 * D5 / 120 + AA3 * D7 / 5040) +
500000
y = M0 * (B0 + B1 * D2 / 2 + B2 * D4 / 24 + B3 * D6 / 720 + B4 * D8 /
40320)
LatLong_to_UTM = Array(x, y)
End Function
Function Sinv(y As Double, Phi As Double) As Double
Dim dY As Double
Dim C As Double
Dim D As Double
Dim C1 As Double
Dim P1 As Double
Dim P2 As Double
Y0 = ss(Application.Degrees(Phi))
dY = y - Y0
C = A * (1# - E2)
D = (1# - E2 * Sin(Phi) * Sin(Phi))
C1 = -3 * E2 / (C * C)
P1 = D ^ (1.5) / C
P2 = C1 * D * D * Cos(Phi)
Sinv = (Phi + dY * P1 + dY * dY * P2)
End Function
Function ss(Phi As Double) As Double
Dim Lat As Double
Lat = Application.Radians(Phi)
ss = (A0 * Lat + A1 * Sin(2# * Lat) + A2 * Sin(4# * Lat) + Err * Sin(6#
* Lat))
End Function