def LatLonToMeters( lat, lon ): import math tileSize = 256 initialResolution = 2 * math.pi * 6378137 / tileSize # 156543.03392804062 for tileSize 256 pixels originShift = 2 * math.pi * 6378137 / 2.0 # 20037508.342789244 mx = lon * originShift / 180.0 my = math.log( math.tan((90 + lat) * math.pi / 360.0 )) / (math.pi / 180.0) my = my * originShift / 180.0 return mx, my