Slippy Map Tiles – How to Count Tiles

slippytiles

I would like to calculate approximately, how many tiles of given size would need to be rendered for a given bounding box and zoom level range in a given projection (always 3857).

For example, for:

  • Tilesize: 256×256 pixels
  • Longitude: 15-25°
  • Latitude 10-20°
  • Zoom levels 5-15

I know that number of tiles at zoom level nx = 4^x.

I think the procedure goes like this: add 1 tile for every level in which one tile is still enough to cover the entire bounding box. For every level further down, assume tiles scale based on the equation above.

Therefore my question is: How do I know the last zoom level on which I can cover the bounding box with 1 tile?

Best Answer

There is more than one approach to this problem. You could approach it by saying that you want to define the top level zoom as 1 x 1 tile (256 x 256 pixels) at the area you care about (which I take from your question is 10 degrees by 10 degrees, but it would be cleaner if you defined it in metres, since that is what you are using with EPSG:3857).

You could choose to use a Well Known Scale Set (see WMTS Appendix E).

You could choose to use TMS (like OpenStreetMap). See http://wiki.openstreetmap.org/wiki/Tile_Disk_Usage

Related Question