Skip to content

Instantly share code, notes, and snippets.

@gabyfle
Created April 1, 2021 08:23
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 gabyfle/674c38051f18c0c02da806bd872a4798 to your computer and use it in GitHub Desktop.
Save gabyfle/674c38051f18c0c02da806bd872a4798 to your computer and use it in GitHub Desktop.
mercator projection
# Using Mercator projection formula
def mercator(lon, lat, width = 14, height = 8):
lon, lat, width, height = float(lon), float(lat), float(width), float(height)
r = width / (2 * PI)
x = r * np.radians(lon)
y = (height / 2) - r * np.log(np.tan(PI / 4 + np.radians(lat) / 2))
return np.array([x, y, 0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment