I am wondering how to find the parent map tiles of a particular tile or the tiles contained within a particular map tile. I know tiles usually have the structure of somedir/{z}/{x}/{y}.png/jpg and I know their is a formula for projecting WGS84-coordinates to tile-names:


E.g. If you change a geometry on a zoom level 18 map tile, do you then have to calculate the tilename on zoomlevels 17 - 1 using the formula to find out which tiles are effected or is there a more efficient way of finding the parents or children of a certain tile?

I have also found this link with notes on how to update tiles, but there seems to be no information concerning my question:


2 Answers 2


Deterministic Tile Names

Every tile has exactly 1 parent tile and 4 children tiles. The naming for these tiles are derived from starting with the world in zoom 0, then dividing the tile into 4 children tiles. Each child tile has one higher zoom level. The x and y values start at 0 in the top left, and increase as you go right and down.

Mapbox has an explorer named What the Tile that you can use to build an intuition around this. Note the tile names are formatted as (x,y,z).

Finding the parent tile

For any z,x,y tile, its parent will be: z-1 / floor(x÷2) / floor(y÷2)

For example, the parent of tile 8/46/90 will be 7/23/45 since 46 ÷ 2 = 23 and 90 ÷ 2 = 45.

The parent of 7/23/45 will be 6/11/22. (floor discards the remainder)

Finding the children tiles

This is a diagram of how to find the four children (z/x/y):

| ----------------------------------------------------|
|    z+1 / x*2 / y*2      |    z+1 / x*2+1 / y*2      |
| ----------------------------------------------------|
|    z+1 / x*2 / y*2+1    |    z+1 / x*2+1 / y*2+1    |
| ----------------------------------------------------|

Which position is my tile in?

Looking at this diagram, you can see that any given tile may be in one of 4 positions of its parent (top-left, top-right, bottom-left, bottom-right). This is why the floor function is used to find the parent.

If you want to know which of these four positions your tile occupies, you can look at the remainders upon diving x and y by two. If x/2 has no remainder, then your tile is on the left. If y/2 has no remainder, your tile is on the top.

For example tile 6/11/22 has parent 5/5/11. Since 11÷2 has remainder 1, we know this tiles position is on the right of its parent. Since 22/2 has remainder 0, we know this tile is on the top of its parent. So 6/11/22 is the top-right division of 5/5/11.


Basically, No. Most of the time, you can simply divide/multiply x and y by 2 when zooming in/out. However, if you look at the equations from the slippy map links you provided, you will note that both lon2tile and lat2tile functions include the FLOOR function, which means that occasionally the series will be x/2-1 or x/2+1 and the same for y, depending on whether you are zooming in or out. Furthermore, while the equation for longitude is linear, the function for latitude includes the arctangent, which is one of the reasons why scale gets distorted in 3857, the further north/south you go.

If you load the Postgres example function, lon2tile and lat2tile, you can quickly generate a few x/y/z combinations and see this effect (or Javscript, Python, Haskell, whatever takes your fancy).

SELECT z, lon2tile(25,z), lat2tile(25,z) FROM generate_series(1, 20) z;

 z  | lon2tile | lat2tile 
  1 |        1 |        0
  2 |        2 |        1
  3 |        4 |        3
  4 |        9 |        6
  5 |       18 |       13
  6 |       36 |       27
  7 |       72 |       54
  8 |      145 |      109
  9 |      291 |      219


There is no deterministic way of knowing when a tile will be a power of 2, relative to a previous layer, and when you will have to +/-1.

The cost of calculting lat/lon to tile and vice versa is so cheap computationally, that I wouldn't think it matters anyway.

  • Thanks for the detailed answer! So if I understand correctly: When editing a very large geometry (e.g. Aral Sea drying up; new political borders) with a large number high zoom tiles (e.g. zoom:18 = 3 million tiles), one would have to calculate the tile name 3'000'000 x 18 = 54'000'000 times to get the names of all effected tiles in all zoom levels?
    – Mfbaer
    Nov 3, 2017 at 12:22
  • Well, that is a different question. But, no, you would not, you would only need to calculate the 4 tiles that would make up the bounding box, of say, the Aral sea at any zoom level. So, for four lat/lon points, this would only be 72, ie, 4 * 18 tile calculations, and the rest you could just fill in. Nov 3, 2017 at 12:38
  • I see where you're going with this (you would theoretically only need 2 tiles: bottomleft & topright i guess). The problem is that if you want to identify which tiles must be rerendered, then a boundingbox is only suboptimally suited, because alot of tiles not needing rerendering would be identified as lying inside the boundingbox and thus be marked to be rerendered. But I guess this is truely another question.
    – Mfbaer
    Nov 3, 2017 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.