Skip to content

Instantly share code, notes, and snippets.

@chinying
Last active June 25, 2018 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chinying/598ffdf55d8b3d2138df72db4b3afdbe to your computer and use it in GitHub Desktop.
Save chinying/598ffdf55d8b3d2138df72db4b3afdbe to your computer and use it in GitHub Desktop.
xy to latlng
from pyproj import Proj, transform
inProj = Proj(init='epsg:3414')
outProj = Proj(init='epsg:4326')
def swap(x, y):
return y, x
def xy_to_latlng(x, y):
return swap(*transform(inProj, outProj, x, y))
def latlng_to_xy(lat, lng):
return transform(outProj, inProj, *swap(lat, lng))
# test, should expect roughly 1.320932, 103.884887
print(xy_to_latlng(33758.4143, 33695.5198))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment