# How to get boundig box coordinates from tile link ? Help please ...

Hi there everybody. I’m still quite new to OpenStreetMap.

I’ve got a simple src tag, allowing me to get one simple map tile, at a given zoom level.

Let’s say my test link is this :

``````<HTML>
<img src="http://tile.openstreetmap.org/16/32742/21790.png" width="256" height="256">
</HTML>
``````

As I can see, zoom 16 is a folder, the X Index of the Map Tile is a folder, and the Y Index is the actual name of the png file.

Now, the question.
Knowing these parameters : Zoom=16 / X=32742 / Y=21790 / Scale=256
how could I get the coordinates of the bounding box of this particular tile ?
I mean the Min Longitude / Max Longitude and Min Latitude / Max Latitude of this tile ?
Is there some kind of furmula to calculate the coordinates from the values in the link ?

Thanks to anyone able to help.

http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

OT: It’s an “img”-tag with a “src”-attribute Thank you Pieren. That’s what I needed.

The “Tile numbers to lon./lat.” pseudo-code, given tile’s X index, Y index and Zoom, returns the coordinate of the Top-Left corner of the tile, which is maximum Lat and minimum Lon.

To get the other 3 points I did as follows :

• Top-Right corner : (X+1) index, Y index, Zoom
• Bottom-Right corner : (X+1) index, (Y+1) index, Zoom
• Bottom-Left corner : (X) index, (Y+1) index, Zoom

If I’d like to know the Center tile’s coordinates I should do as follows, I guess :
LatCenter = LatMin + ( LatMax - LatMin ) / 2
LonCenter = LonMin + ( LonMax - LonMin ) / 2

Another little question :

If I copy image link in my browser on each OSM’s map tile, at different zoom levels, I get links as follows :

What are those “a.”, “b.”, “c.” letters ?

I see that tiles are also available without them in the link :

They are only aliases for tile.openstreetmap.org, because most browsers restrict their connections per host.

Got it. Thanks. Complete Openstreetmap single tile to lat/lon corners conversion

``````def tile_corners_to_latlon(xtile, ytile, zoom):
n = 2.0 ** zoom
lon_deg = xtile / n * 360.0 - 180.0
lat_rad_nw = math.atan(math.sinh(math.pi * (1 - 2 * (ytile / n))))

lat_rad_se = math.atan(math.sinh(math.pi * (1 - 2 * ((ytile + 1) / n))))