Skip to content

Instantly share code, notes, and snippets.

@marcelino-m
Last active April 24, 2020 22:04
Show Gist options
  • Save marcelino-m/2d188f92255fdf60a3c804cf31414feb to your computer and use it in GitHub Desktop.
Save marcelino-m/2d188f92255fdf60a3c804cf31414feb to your computer and use it in GitHub Desktop.
Transformacion de coordenadas DMH
import pyproj
def utm2dmh(x, y):
"""Transformacion coordenadas WGS84/UTM 19S a DMH"""
a1 = 1.01340872464667
b1 = 0.000356424618826433
c1 = -509325.431674420
a2 = -0.00134028501767773
b2 = 1.00293580527335
c2 = -7521032.85359513
xw = a1 * x + b1 * y + c1
yw = a2 * x + b2 * y + c2
return (xw, yw)
def dmh2utm(x, y):
"""Transformacion coordenadas DMH a WGS84/UTM 19S"""
a1 = 0.986768226550342
b1 = -0.000350678963866868
c1 = 499948.684942048
a2 = 0.00131867928436894
b2 = 0.997072319815812
c2 = 7499685.311640785
xm = a1 * x + b1 * y + c1
ym = a2 * x + b2 * y + c2
return (xm, ym)
def dmh2lonlat(x, y):
"""Transformacion coordenadas DMH a WGS84"""
soure = pyproj.Proj(init="EPSG:32719")
target = pyproj.Proj(init="EPSG:4326")
coord = dmh2utm(x, y)
return pyproj.transform(soure, target, coord[0], coord[1])
def lonlat2dmh(lon, lat):
"""Transformacion coordenadas WGS84 a DMH"""
soure = pyproj.Proj(init="EPSG:4326")
target = pyproj.Proj(init="EPSG:32719")
coord = pyproj.transform(soure, target, lon, lat)
return utm2dmh(coord[0], coord[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment