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

Hi there everybody. :slight_smile:
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.

You will find all your answers here:

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

OT: It’s an “img”-tag with a “src”-attribute :wink:

Thank you Pieren. :slight_smile:

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 :

http://tile.openstreetmap.org/15/16371/10895.png
http://tile.openstreetmap.org/16/32743/21791.png
http://tile.openstreetmap.org/17/65486/43583.png

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

Got it. Thanks. :slight_smile: