Google Maps Revisited

Mike Williams provided some great feedback on my last post about Google Maps and coordinate systems. Let’s look into two of his comments in more depth.

First, he pointed out that my formula for calculating the number of tiles was a bit misleading:

 Math.pow(2, zoom)

This actually tells you either the number of tiles across or the number of tiles down. So at zoom level 2, there are 4 tiles across and 4 tiles down, for a total of 16. Thus, the correct formula is:

 Math.pow(2, zoom)

Its worth stopping and thinking about this for a minute. Let’s do the math and see how many tiles Google has to generate to cover the Earth at different zoom levels.

ZoomTiles
01
14
216
364
4256
51,024
64,096
716,384
865,536
9262,144
101,048,576
114,194,304
1216,777,216
1367,108,864
14268,435,456
151,073,741,824
164,294,967,296
1717,179,869,184
1868,719,476,736
19274,877,906,944
201,099,511,627,776

At zoom level 20, it would require over 1 trillion tiles to cover the Earth.

Let’s do a quick back of the envelope calculation to figure out the storage requirements. If you download one of the image tiles, you’ll see that its an 8 bit png. I checked a few images of areas over land and saw that their sizes ranged from 8 to 16k.

So let’s say each land image occupies 10k, and that land occupies 25% of the Earth’s surface. Each ocean image is roughly 100 bytes, so let’s just ignore those (which is reasonable, since you only need to produce one nice blue png image as long as you don’t want to create any with labels like “Pacific Ocean”).

So as a rough estimate, the storage requirements in bytes can be calculated as:

0.25 * numberOfTiles * 10000

Working out the math we see:

Zoom LevelSize (terrabytes)
120.04
130.17
140.68
152.7
1610.7
1743
18170
19690
202750

At zoom level 14 you need 680 gigabytes of storage capacity, about the size of the largest hard drives available today. But remember the growth is exponential, so at zoom level 15 you need 2.7 terrabytes space. By the time you reach zoom level 120 you’ll need 2,750 terrabyes. Of course
all the zoom levels are cumulative. If add up the total its around 3,700 terrabytes – a number that just a few years ago would have been unimaginable but I’m sure is commonplace today for Google, Yahoo, Amazon, Yahoo, etc. Assuming you use 500 Gigabyte hard drives, that would be 7,400 harddrives, not counting the same number needed to create a single backup.

The second point Mike brought up is that the farthest north, or south, that Google Maps covers is 85.05112877980660 degrees. How did they come up with that number? I have to admit I never considered it, but the answer is quite clever. It creates a perfect square – which of course is a lot easier to work with than a rectangle.

How do we know that – well let’s work through an example to see. At zoom level 0 we know that we want to cover the Earth with a single 256 by 256 pixel bitmap. Remembering from last time, to convert from y to latitude we use this formula:

 yToLat: function(y)
  {
    var latitude =  (Math.PI/2) - 
                    (2 * Math.atan(
                       Math.exp(-1.0 * y / this.radius)));
    return Math.radiansToDegrees(latitude);
  }

Using a y value of 128 (we’ll ignore the false northing that Google uses) and a radius of 40.74 (256/2*Pi) the answer – you guessed it – is 85.05112877980660.

Thanks again Mike for the comments! And for anyone interested, Mike maintains a great set of tutorials about Google Maps that you should check out.

  1. July 7, 2006

    Thanks for that analysis Charlie, I wondered for a while how much data Google needed to store to get that service running – now you’ve put that into perspective.

  2. hinkle
    February 4, 2008

    It’s worth noting that google does not have a full set of tiles at every zoom level.

Top