3 ms·
There is no controversy IMHO. [Lat,Lon] is just different coordinate system of the same space as is [X,Y]. It never happens that you try to generate {X} from {
by timonoko 5y ago
There is no controversy IMHO. [Lat,Lon] is just different coordinate system of the same space as is [X,Y].
It never happens that you try to generate {X} from {Lon} alone.
def LatLon_to_GoogleTiles(lat, lon, zoom):
lat_rad = math.radians(lat)
n = 2.0 ** zoom
xtile = int((lon + 180.0) / 360.0 * n)
ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
return (xtile, ytile)