Skip to content

Instantly share code, notes, and snippets.

@smakhtin
Created October 25, 2015 11:33
Show Gist options
  • Save smakhtin/074e04a184f7df32157e to your computer and use it in GitHub Desktop.
Save smakhtin/074e04a184f7df32157e to your computer and use it in GitHub Desktop.
Convert to and from Web Mercator
import math
def y2lat(a):
return 180.0/math.pi*(2.0*math.atan(math.exp(a*math.pi/180.0))-math.pi/2.0)
def lat2y(a):
return 180.0/math.pi*math.log(math.tan(math.pi/4.0+a*(math.pi/180.0)/2.0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment