Taken from MIND LINK! on Fri Mar 3 12:06:06 1995 Fri Mar 3 11:13:28 1995 Letter : 3660636 From: Ken Hill Address : khill@HUSKY1.STMARYS.CA Subject : Long/Lat-UTM Conversion Bytes : 3209 To: SARINFO@mindlink.bc.ca (Bob Manson) --========================_7401426==_ Content-Type: text/plain; charset="us-ascii" Bob: I tracked down the bug in the conversion code and am sending along a text file with the revised basic code and a little explanation on how the conversion is done. Give it a try. I also have a slightly more sophisticated (compiled) version which allows for the UTM to Long/Lat conversion as well. If you're interested I could send it to for uploading to your BBS. Let me know. Regards, Ken Hill khill@husky1.stmarys.ca --========================_7401426==_ Content-Type: text/plain; name="GEO-UTM.TXT"; charset="us-ascii" Content-Disposition: attachment; filename="GEO-UTM.TXT" Equation for Converting Long/Lats to UTM Coordinates Ken Hill ( khill@husky1.stmarys.ca ) Waverley SAR, Nova Scotia VARIABLES: LG = longitude to be converted LT = latitude to be converted CONSTANTS: K0 = .0009996 B1 = 16216.944156 C1 = 17.2093715258 A = 7495.8054646 E = .00676865799783 E1 = .00681478594645 K3 = 309100.43 K4 = 121.08712 A1 = 111132.092423 EQUATIONS: Z = UTM number = INT[(180-LG)/6]+1 C = Central Meridian = 183-(6*Z) P = .36*ABS(C-LG) N = UTM Y coordinate (kilometers) = K0*{A1*LT-B1*SIN(2*LT)+C1*SIN(4*LT)+P2*A*SIN(LT)*COS(LT)/SQR[1-E*SIN2(LT)]} E2 = distance from Central Meridian (kilometers) = .001*{P*K3*COS(LT)+P3*K4*COS3(LT)*[1-TAN2(LT)+E1*COS2(LT)]}/SQR[1-E*SIN2(LT) ] (NOTE: if the point being converted is west of the Central Meridian, E2 is subtracted from 500 km. If the point is east of the CM, E2 is added to 500 km.) Sample BASIC Program for Conversion: 10 DEFDBL A-Z : REM use double precision math 11 CLS 12 PRINT "LONGS/LATS to UTM Conversion" : PRINT 15 PI = 3.14159265359 : K0 = .0009996 : B1 = 16216.944156 : C1 = 17.2093715258 50 A = 7495.8054646 : E = .00676865799783 : E1 = .00681478594645 80 K3 = 309100.43 : K4 = 121.087180418 : A1 = 111132.092423 130 INPUT "LONGITUDE Degrees (0-180)";LG 132 INPUT "LONGITUDE Minutes (0-60);Q1 : IF Q1 > 60 THEN BEEP : GOTO 132 133 REM Enter seconds as a fraction of a minute 134 Q1 = Q1 * 1/60 : LG = LG + Q1 : PRINT 140 INPUT "LATITUDE Degrees (0-80)";LT 142 INPUT "LATITUDE Minutes (0-60)";Q2 : IF Q2 > 60 THEN BEEP : GOTO 142 144 Q2 = Q2 * 1/60 : LT = LT + Q2 150 Z = INT((186 - LG) / 6) : REM Compute UTM Zone 160 L3 = LT : LT = (LT/360) * (2 * PI) : REM Convert LT into radians 170 C = 183 - 6 * Z : P = .36 * ABS(C - LG) 180 N =K0*(A1*L3-B1*SIN(2*LT)+C1*SIN(4*LT)+P^2*A*SIN(LT)*COS(LT)/SQR(1-E*SIN(LT)^2 )) 190 E2 = .001*(P*K3*COS(LT)+P^3*K4*COS(LT)^3*(1-TAN(LT)^2+E1*COS(LT)^2))/SQR(1-E* SIN(LT)^2) 200 IF LG > C THEN E2 = 500 - E2 ELSE E2 = 500 +E2 205 PRINT "Longitude = ";LG;: PRINT " Latitude = ";L3 210 PRINT : PRINT "UTM = ";E2;N 215 E2 = INT(E2*10+.5): E$ = STR$(E2) : E$ = MID$(E$,3,3) : REM Get 6-digit grid reference 225 N = INT(N*10+.5): N$ = STR$(N) : N$ = MID$(N$,4,3) 230 PRINT "Six Digits = ";E$;" ";N$ 240 PRINT: INPUT "Do you want another run (y/n)";W$ 250 IF W$ = "y" or W$ = "Y" then RUN --========================_7401426==_--