Projection

To make the map seamless and ensure proper overlay of data from different sources, it is necessary to use one projection for the entire planet. We use Mercator projection on a sphere to simplify calculations, since in this case only map display is required, not coordinate definition.

General view of the projection

Since the Mercator projection approaches infinity at the poles, in reality it does not cover the entire planet, but is limited by latitude +/- 85.051129 degrees.

This projection is also called Web Mercator and is used by major web map providers, including Google Maps, Bing Maps, OpenStreetMap, Esri, Mapbox and many others.

The projection has identifier EPSG: 3857.

Map Size and Scale

To render the map, it is necessary to know its size or scale. At the lowest level of detail (level 0), the map has a size of 256 x 256 pixels, at each subsequent level the width and height of the map increase by 2 times: level 1 is 512 x 512 pixels, level 2 is 1024 x 1024 pixels, and so on. In general, the dimensions are calculated as follows:

map_w = map_h = 256 * 2 ^ z

where z in our system can have values from 0 to 19.

The radius of the sphere in the Mercator projection is taken as 6378137 meters, then knowing the map dimensions, you can get the resolution in meters per pixel and further — the map scale.

The table below shows the relationships between these values at the equator.

LevelWidth and height (pix.)Resolution (m/pix.)Scale
0256156543.03391:591658710.91
151278271.51701:295829355.45
2102439135.75851:147914677.73
3204819567.87921:73957338.86
440969783.93961:36978669.43
581924891.96981:18489334.72
6163842445.98491:9244667.36
7327681222.99251:4622333.68
865536611.49621:2311166.84
9131072305.74811:1155583.42
10262144152.87411:577791.71
1152428876.43701:288895.85
12104857638.21851:144447.93
13209715219.10931:72223.96
1441943049.55461:36111.98
1583886084.77731:18055.99
16167772162.38871:9028.00
17335544321.19431:4514.00
18671088640.59721:2257.00
191342177280.29861:1128.50