Convertir Coordenadas GTM a Geodésicas (Geográficas)

Les dejo el código de cómo convertir coordenadas GTM (Guatemala Transverse Mercator) a coordenadas Geográficas y Viceversa.

Me basé en la información de la pagina siguiente convertir-coordenadas-utm-geodesicas


    Const SeMayor = 6378137             'Semi major axis (a) (m)
    Const FaloEste = 500000             'Falso Este (m)/Falso Norte Es "0"
    Const CSF = 0.9998                  'Escala de Factor Central (CSF)
    Const ZD = 6                        'Zona ancho (en grados)
    Const LCMZ = -90.5                  'Longitud del meridiano central en zona 1(grados)
    Const iflat = 298.257223563         'achatamiento invereso (1/f)


    '''

    ''' Convierte Coordenadas GTM a Geodésicas (Geográficas)
    '''

    ''' Coordenada X
    ''' Coordenada Y
    ''' Zona
    ''' Vector con Coordenadas X,Y  (1)(2)

    '''
    Public Shared Function aGeodesicas(ByVal CoorX As Double, ByVal CoorY As Double, ByVal Zona As Integer) As Double()

        '******************************************
        'Variables de Generales para el Calculo
        '******************************************

        'Achatamiento (f)
        Dim flat As Double = 1 / iflat
        'Excentricidad (e2)
        Dim Ex As Double = (2 * flat) - (flat * flat)
        'Semi-minor axis
        Dim SeMenor As Double = SeMayor * (1 - flat)

        Dim n As Double = (SeMayor - SeMenor) / (SeMayor + SeMenor)
        Dim n2 As Double = n ^ 2
        Dim n3 As Double = n ^ 3
        Dim n4 As Double = n ^ 4
        Dim G As Double = SeMayor * (1 - n) * (1 - n2) * (1 + (9 * n2) / 4 + (255 * n4) / 64) * PI / 180

        'Parte Norte
        Dim m As Double = CoorY / CSF
        Dim Sigma As Double = (m * PI) / (G * 180)
        Dim Sigma2 As Double = Sigma * 2
        Dim Sigma4 As Double = Sigma * 4
        Dim Sigma6 As Double = Sigma * 6
        Dim Sigma8 As Double = Sigma * 8

        'Parte Este
        Dim Este As Double = CoorX - FaloEste

        'Foot Point latitude
        Dim Term1 As Double = Sigma
        Dim Term2 As Double = ((3 * n / 2) - (27 * n3 / 32)) * Sin(Sigma2)
        Dim Term3 As Double = ((21 * n2 / 16) - (55 * n4 / 32)) * Sin(Sigma4)
        Dim Term4 As Double = (151 * n3) * Sin(Sigma6) / 96
        Dim Term5 As Double = 1097 * n4 * Sin(Sigma8) / 512

        Dim Lat As Double = Term1 + Term2 + Term3 + Term4 + Term5
        Dim SinLat As Double = Sin(Lat)
        Dim SecLat As Double = 1 / Cos(Lat)

        'Radios de curvatura
        Dim Rho As Double = SeMayor * (1 - Ex) / (1 - Ex * SinLat * SinLat) ^ 1.5
        Dim Nu As Double = SeMayor / (1 - Ex * SinLat * SinLat) ^ 0.5

        'x = E'/(k0n')
        Dim x As Double = (Este / CSF) / Nu
        'Dim x2 As Double = x ^ 2
        Dim x3 As Double = x ^ 3
        'Dim x4 As Double = x ^ 4
        Dim x5 As Double = x ^ 5
        'Dim x6 As Double = x ^ 6
        Dim x7 As Double = x ^ 7

        't'=tanj'
        Dim t As Double = Tan(Lat)
        Dim t2 As Double = t ^ 2
        'Dim t3 As Double = t ^ 3
        Dim t4 As Double = t ^ 4
        'Dim t5 As Double = t ^ 5
        Dim t6 As Double = t ^ 6

        'y'=n'/r'
        Dim y As Double = Nu / Rho
        Dim y2 As Double = y ^ 2
        Dim y3 As Double = y ^ 3
        Dim y4 As Double = y ^ 4


        'Latitud
        Dim Tm1 As Double = -((t / (CSF * Rho)) * x * Este / 2)
        Dim Tm2 As Double = (t / (CSF * Rho)) * ((x3) * Este / 24) * (-4 * y2 + 9 * y * (1 - t2) + 12 * t2)
        Dim Tm3 As Double = -(t / (CSF * Rho)) * ((x5) * Este / 720) * (8 * y4 * (11 - 24 * t2) - 12 * y3 * (21 - 71 * t2) + 15 * y2 * (15 - 98 * t2 + 15 * t4) + 180 * y * (5 * t2 - 3 * t4) + 360 * t4)
        Dim Tm4 As Double = (t / (CSF * Rho)) * ((x7) * Este / 40320) * (1385 + 3633 * t2 + 4095 * t4 + 1575 * t6)
        Dim SumTm As Double = Lat + Tm1 + Tm2 + Tm3 + Tm4

        'Latitud geodesica
        Dim Latitud As Double = (SumTm / PI) * 180

        'Meridiano Central
        Dim CMDeg As Double = (Zona * ZD) + LCMZ - ZD
        Dim CMRad As Double = (CMDeg / 180) * PI

        Dim lon1 As Double = SecLat * x
        Dim lon2 As Double = -SecLat * ((x3) / 6) * (y + 2 * t2)
        Dim lon3 As Double = SecLat * ((x5) / 120) * (-4 * y3 * (1 - 6 * t2) + y2 * (9 - 68 * t2) + 72 * y * t2 + 24 * t4)
        Dim lon4 As Double = -SecLat * ((x7) / 5040) * (61 + 662 * t2 + 1320 * t4 + 720 * t6)

        Dim SumLon As Double = CMRad + lon1 + lon2 + lon3 + lon4

        Dim Longitud As Double = (SumLon / PI) * 180

        Dim Coordenadas(2) As Double
        Coordenadas(1) = Latitud
        Coordenadas(2) = Longitud

        Return Coordenadas

    End Function

Este es el código que convierte Coordenadas Geográficas a GTM

    '''

    ''' Convierte Coordenadas Geodésicas a GTM
    '''

    ''' GTM X
    ''' GTM Y
    ''' Zona
    ''' Vector Con Coordenadas Geodésicas

    '''
    Public Shared Function aGTM(ByVal CoorX As Double, ByVal CoorY As Double, ByVal Zona As Integer) As Double()

        '******************************************
        'Variables de Generales para el Calculo
        '******************************************

        'Achatamiento (f)
        Dim flat As Double = 1 / iflat
        'Excentricidad (e2)
        Dim Ex As Double = (2 * flat) - (flat * flat)
        'Semi-minor axis (b) (m)
        'Dim SeMenor As Double = SeMayor * (1 - flat)

        'Radianes Este
        Dim Re1 As Double = CoorX / 180 * PI
        Dim Re2 As Double = LCMZ / 180 * PI

        'Radianes Norte
        Dim Rn1 As Double = CoorY / 180 * PI
        Dim Rn2 As Double = (CoorY - LCMZ) / 180 * PI

        'Seno Latitud
        Dim SinLat As Double = Sin(Re1)
        Dim SinLat2 As Double = Sin(2 * Re1)
        Dim SinLat4 As Double = Sin(4 * Re1)
        Dim SinLat6 As Double = Sin(6 * Re1)

        'Excentricidad
        Dim Ex2 As Double = Ex
        Dim Ex4 As Double = Ex ^ 2
        Dim Ex6 As Double = Ex ^ 3

        'Las As
        Dim A0 As Double = 1 - (Ex2 / 4) - ((3 * Ex4 / 64) - ((5 * Ex6) / 256))
        Dim A2 As Double = (3 / 8) * (Ex2 + (Ex4 / 4) + ((15 * Ex6) / 128))
        Dim A4 As Double = (15 / 256) * (Ex4 + ((3 * Ex6) / 4))
        Dim A6 As Double = (35 * Ex6) / 3072

        'Distancia del Meridano
        Dim Term1 As Double = SeMayor * A0 * Re1
        Dim Term2 As Double = -SeMayor * A2 * SinLat2
        Dim Term3 As Double = SeMayor * A4 * SinLat4
        Dim Term4 As Double = SeMayor * A6 * SinLat6
        Dim Md As Double = Term1 + Term2 + Term3 + Term4

        'Radio de Curvatura
        Dim Rho As Double = SeMayor * (1 - Ex2) / (1 - (Ex2 * SinLat * SinLat)) ^ 1.5
        Dim Nu As Double = SeMayor / (1 - (Ex2 * SinLat * SinLat)) ^ 0.5

        'Powers
        Dim Pow1 As Double = Cos(Re1)
        Dim Pow2 As Double = Pow1 ^ 2
        Dim Pow3 As Double = Pow1 ^ 3
        Dim Pow4 As Double = Pow1 ^ 4
        Dim Pow5 As Double = Pow1 ^ 5
        Dim Pow6 As Double = Pow1 ^ 6
        Dim Pow7 As Double = Pow1 ^ 7

        'Diferencia de Longitud
        Dim Dlong1 As Double = Rn2
        Dim Dlong2 As Double = Dlong1 ^ 2
        Dim Dlong3 As Double = Dlong1 ^ 3
        Dim Dlong4 As Double = Dlong1 ^ 4
        Dim Dlong5 As Double = Dlong1 ^ 5
        Dim Dlong6 As Double = Dlong1 ^ 6
        Dim Dlong7 As Double = Dlong1 ^ 7
        Dim Dlong8 As Double = Dlong1 ^ 8

        'Tangente de Latitud
        Dim Tan1 As Double = Tan(Re1)
        Dim Tan2 As Double = Tan1 ^ 2
        Dim Tan4 As Double = Tan1 ^ 4
        Dim Tan6 As Double = Tan1 ^ 6

        'Psi Nu/Rho
        Dim Psi1 As Double = Nu / Rho
        Dim Psi2 As Double = Psi1 ^ 2
        Dim Psi3 As Double = Psi1 ^ 3
        Dim Psi4 As Double = Psi1 ^ 4

        'Este
        Dim E1 As Double = Nu * Dlong1 * Pow1
        Dim E2 As Double = Nu * Dlong3 * Pow3 * (Psi1 - Tan2) / 6
        Dim E3 As Double = Nu * Dlong5 * Pow5 * (4 * Psi3 * (1 - 6 * Tan2) + Psi2 * (1 + 8 * Tan2) - Psi1 * (2 * Tan2) + Tan4) / 120
        Dim E4 As Double = Nu * Dlong7 * Pow7 * (61 - 479 * Tan2 + 179 * Tan4 - Tan6) / 5040

        Dim Sume As Double = E1 + E2 + E3 + E4
        Dim Sume2 As Double = CSF * Sume

        Dim Est = Sume2 + FaloEste

        'Norte
        Dim N1 As Double = Nu * SinLat * Dlong2 * Pow1 / 2
        Dim N2 As Double = Nu * SinLat * Dlong4 * (4 * Psi2 + Psi1 - Tan2) / 24
        Dim N3 As Double = Nu * SinLat * Dlong6 * (8 * Psi4 * (11 - 24 * Tan2) - 28 * Psi3 * (1 - 6 * Tan2) + Psi2 * (1 - 32 * Tan2) - Psi1 * (2 * Tan2) + Tan4) / 720
        Dim N4 As Double = Nu * SinLat * Dlong8 * Pow7 * (1385 - 3111 * Tan2 + 543 * Tan4 - Tan6) / 40320
        Dim SumN As Double = Md + N1 + N2 + N3 + N4

        Dim sumN1 As Double = CSF * SumN
        Dim Norte As Double = sumN1

        Dim Coordenadas(2) As Double
        Coordenadas(1) = Est
        Coordenadas(2) = Norte

        Return Coordenadas

    End Function



Cualquier duda o sugerencia, sea bienvenida

Comentarios

guichogp dijo…
amigo este codigo es en java o visual basic o en que programa
CHIVOPOETA dijo…
y no tendrán una aplicación ejecutable para eso?
Anónimo dijo…
porque no vas y chiflas a tu mauser
el código es Visual Basic
Rony Carias dijo…
Hola amigo, gracias por compartir. Te comento que estoy programando una aplicacoin en Android que usa el GPS del telefono y pues me interesaria convertir las coordenadas del telefono que son en geograficas a GTM, logre convertirlas a UTM y a grados sexagesimales con unas formulas que encontre en el la fuente que citan en la pagina que vos citas. Intente traducir tu codigo a Android pero me dio resultados erroneos. No se si traduje mal. Me gustaria saber si usaste otra fuenta para la conversion a GTM que es la que me falta. De nuevo gracias
Anónimo dijo…
Buenas noches, siempre quise saber la manera en que se realiza este calculo o transformacion de coordenadas, me parece fabuloso que se comparta todo material y sobre todo este en especial. Felicidades y de verdad que muy agradecido con el aporte.

Saludos.
Rony Carias. Te cuento que fue lo única fuente que utilicé para la conversión...

Para traducirlo a Android... debería de funcionar