Calculate google tile boundary coordinates

I did a lot of searching and found some helpful resources, but I still have problems calculating.

I want to calculate the NE and SW coordinates for a specific tile.

This is my way:

Zoom = 11
x = 1188 
y = 767

number of tile = 2 ^ 11 (equals 2048)
angle1 = 360 / 2048
longitude = (1188 * angle1) - 180

      

it works correctly.

But the latitudinal part is not:

angle2 = 170.1022575596 / (2048/2)
latitude = ((2048 / 2) - 767) * angle2

      

early

+3


source to share


1 answer


The solution you are looking for is:

z = 11
x = 1188 
y = 767

pi = 3.14159

alon1 = (x /2^z)*360.0 - 180.0
alon2 = ((x+1) /2^z)*360.0 - 180.0

an   = pi-2*pi*y/2^z
alat1 = 180.0/pi*atan(0.5*(exp(an)-exp(-an)))
an   = pi-2*pi*(y+1)/2^z
alat2 = 180.0/pi*atan(0.5*(exp(an)-exp(-an)))

      



And you will get the NW (alon1, alat1) and SE (alon2, alat2) coordinates for that particular tile.

0


source







All Articles